Is there any way to know if my application is running on the emulator or on the device ?
Asked
Active
Viewed 709 times
2 Answers
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
-
1It doesn't work with emulator running in 2.2. It returns an ID. – Arutha Nov 02 '10 at 17:51
-
1@Arutha: Yes, that is new behavior for Android 2.2 – CommonsWare Nov 02 '10 at 19:59