简体   繁体   中英

How can I limit my android application installed on real device only?

I expect that my android application is allowed to install only on real device, and android-emulator can't.How can I limit my android application installed on real device only ? Thanks for any replies.

遗憾的是,您无法阻止人们在模拟器中安装,但如果您安装了Google许可证 ,则会确保它不会在未经许可的设备上运行。

There's one way how to handle it. Just check device id (IMEI code). For emulator it's always null , so you can define either someone tries to launch it in real device or in emulator.

    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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM