![](/img/trans.png)
[英]how can i locate an android device with a website and communicate with an application installed on it
[英]How can I limit my android application installed on real device only?
我希望我的android應用程序只允許在真實設備上安裝,並且android-emulator不能。我怎樣才能限制我的安裝在真實設備上的android應用程序? 謝謝你的回復。
遺憾的是,您無法阻止人們在模擬器中安裝,但如果您安裝了Google許可證 ,則會確保它不會在未經許可的設備上運行。
有一種方法可以處理它。 只需檢查設備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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.