5

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

Arutha
  • 26,088
  • 26
  • 67
  • 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,210
  • 1
  • 14
  • 21
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
  • 986,068
  • 189
  • 2,389
  • 2,491