5

Is there any way to know if my application is running on the emulator or on the device ?

Arutha
  • 25,280
  • 26
  • 65
  • 80

2 Answers2

4

I am using this code snippet which works on both Intel and ARM emulators:

if (Build.MODEL.contains("google_sdk") ||
    Build.MODEL.contains("Emulator") ||
    Build.MODEL.contains("Android SDK")) {
  RunsInEmulator = true;
}
Ernie
  • 1,172
  • 1
  • 13
  • 20
3
Secure.getString(getContentResolver(), Secure.ANDROID_ID); 

(where Secure is android.provider.Settings.Secure)

That value will be null on the emulator, non-null on devices.

CommonsWare
  • 954,112
  • 185
  • 2,315
  • 2,367