Determine If Emulator Device Is In Use
Does anyone know what the method hasClients does in the android sdk? boolean com.android.ddmlib.IDevice.hasClients() It doesn't look like its documented. I am trying to find a way
Solution 1:
Have a look at this question to figure out if you are running in the emulator: How can I detect when an Android application is running in the emulator?
On a monkey-related point, you might want to have a look at Activity.isUserAMonkey() method (since API level 8, OS 2.2). The Google DeviceAdminSample code gives a brief explanation:
/**
* If the "user" is a monkey, post an alert and notify the caller. This prevents automated
* test frameworks from stumbling into annoying or dangerous operations.
*/privatestatic boolean alertIfMonkey(Context context, int stringId) {
if (ActivityManager.isUserAMonkey()) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage(stringId);
builder.setPositiveButton(R.string.monkey_ok, null);
builder.show();
returntrue;
} else {
returnfalse;
}
}
Post a Comment for "Determine If Emulator Device Is In Use"