android - 如何限制我的 android 应用程序只安装在真实设备上?

标签 android android-emulator apk android-install-apk

我希望我的 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/

相关文章:

android - 如何使用 HttpClient(或其他 HTTP 类)异步检索 JSON

android - 颤振 : Google Play services out of date

android - Android模拟器如何支持其他语言?

android - 如何获取存储在SD卡中的图片数量

android - 缺少创建新 AS 项目并在安装后在我的设备上填充 lib 文件夹的步骤

javascript - 如何在不再次发送所有 APK 的情况下更新我的应用程序?

图像上的 Android 手势

Android:3d 安全重定向响应

java - 仅当我从 Playstore 下载时才会在应用程序中出现此登录问题

android - 如何通过 Bluestacks 在 Mac 上运行 apk 文件