Wednesday, September 29, 2010
Wednesday, September 1, 2010
Detect if code runs into emulator
Working on my app i had needs to know if the code was running into emulator but Android doesn't have any API to detect it so i wrote a little function which returns 'true' if emulator is present:
ANDROID_ID is null on 'old' emulators, since 2.2 the id is always '9774D56D682E549C'.
Hope this help ;)
public static boolean isEmulator() {
String id = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
boolean emulator = TextUtils.isEmpty(id);
if (!emulator) {
emulator = id.toUpperCase().equals("9774D56D682E549C");
}
return emulator;
}
ANDROID_ID is null on 'old' emulators, since 2.2 the id is always '9774D56D682E549C'.
Hope this help ;)
Subscribe to:
Posts (Atom)