我希望我的 android 应用程序只能安装在真实设备上,而 android-emulator 不能。如何限制我的 android 应用程序只能安装在真实设备上? 感谢您的任何回复。
最佳答案
有一种方法可以处理它。只需检查设备 ID(IMEI 代码)。对于模拟器,它始终为 null
,因此您可以定义有人尝试在真实设备或模拟器中启动它。
TelephonyManager tm=(TelephonyManager )activity.getSystemService(Context.TELEPHONY_SERVICE);
if(tm==null || !this.hasTelephony())
{
Log.v(TAG, "Can't get telephony service. Forcing shut down!");
return false;
}
String deviceId=tm.getDeviceId();
if(deviceId==null || deviceId.length() < 2)
{
Log.v(TAG, "Looks like emulator - bail out!");
Toast.makeText(activity, "This special version not intended to run in this device!", 5000).show();
return false;
}
关于android - 如何限制我的 android 应用程序只安装在真实设备上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8800264/