3

我想阻止用户在模拟器上注册,那么如何确定apk是在模拟器上运行还是在真实设备上运行?谢谢!

4

2 回答 2

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" />
于 2013-03-12T02:40:47.190 回答
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();
              }
于 2013-03-12T02:57:32.863 回答