I would like to prevent user from registering on emulator, so how to determine whether apk is running on emulator or real device? Thank you!
Asked
Active
Viewed 4,623 times
3
-
Perhaps check if Google Play is installed? It's hard as hell to install Google Play in an emulator – Rotary Heart Mar 12 '13 at 02:33
-
1Haven't tried any of the solutions, but [start here](http://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator). Keep in mind that no methods are full proof. – A--C Mar 12 '13 at 02:33
-
1Maybe this will help: [http://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator][1] [1]: http://stackoverflow.com/questions/2799097/how-can-i-detect-when-an-android-application-is-running-in-the-emulator – Gabriel Mar 12 '13 at 02:34
-
In general the system propery Google uses is "ro.kernel.qemu". If this returns "1" then you are running on an emulator – EyalBellisha Mar 12 '13 at 09:31
-
check this out: http://stackoverflow.com/a/21505193/878126 – android developer Feb 01 '14 at 23:47
2 Answers
0
You can check the device id which is hardcoded into emulator. For checking :
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Log.e("id", telephonyManager.getDeviceId());
And the result should be something like this:
03-12 09:50:08.043: E/id(447): 000000000000000
With permission
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

toantran
- 1,789
- 17
- 25
0
Try this
if (Build.BRAND.equalsIgnoreCase("generic")) {
Toast.makeText(getBaseContext(), "YES, I am an emulator", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getBaseContext(), "NO, I am NOT an emulator", Toast.LENGTH_LONG).show();
}

AwadKab
- 3,054
- 2
- 17
- 17