3
我想阻止用户注册模拟器,所以如何确定apk是否在模拟器或真实设备上运行?谢谢!如何确定apk是否在模拟器或真实设备上运行?
我想阻止用户注册模拟器,所以如何确定apk是否在模拟器或真实设备上运行?谢谢!如何确定apk是否在模拟器或真实设备上运行?
您可以检查硬编码为模拟器的设备ID。 对于检查:
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
Log.e("id", telephonyManager.getDeviceId());
而且结果应该是这样的:
03-12 09:50:08.043: E/id(447): 000000000000000
随着许可
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
试试这个
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();
}
或许检查,如果谷歌Play是安装?在模拟器中安装Google Play非常困难 – 2013-03-12 02:33:15
还没有尝试过任何解决方案,但[从这里开始](http://stackoverflow.com/questions/2799097/how-can-i-detect-when-an -Android-应用被运行 - 内式仿真器)。请记住,没有方法是充分的证据。 – 2013-03-12 02:33:26
也许这将有助于: [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 – jackgris 2013-03-12 02:34:45