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:

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 ;)


  1. Actually Droid 2 and some other customized 2.2 rom return the same magic '9774D56D682E549C', so there is no precise way to detect it's emulator or not

  2. It's actually a bug and all the Froyo devices that i've used respond to the same Android_id