我想阻止用户在模拟器上注册,那么如何判断apk是否在模拟器或真实设备上运行?谢谢!
答案 0 :(得分:0)
您可以检查硬编码到仿真器中的设备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" />
答案 1 :(得分:0)
试试这个
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();
}