如何限制 APK 不安装在 Android Emulator/Simulator 中,而是安装在真实设备中? [英] How to restrict an APK not to get installed in Android Emulator/Simulator but in real device?

查看:26
本文介绍了如何限制 APK 不安装在 Android Emulator/Simulator 中,而是安装在真实设备中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望您知道,可以借助 Astro 文件管理器等应用程序将安装在 android 设备中的应用程序备份并存储为可安装文件(作为 APK 文件).同样的 apk 也可以安装在 android 模拟器中.因此,其他人有机会轻松挖掘已安装应用程序的文件,如 DB、共享首选项等.

Hope you know that an application which is installed in an android device can be backed up and stored as an installable file(as an APK file) with the help of apps like Astro file manager. The same apk can be installed in the android simulator as well. So there is a chance that other can easily dig into the installed app's files like DB, shared preference, etc..

有没有办法只允许在真机上安装而不是在模拟器上安装???

Is there any way to permit installing only in real device and not in simulators???

我知道,如果它是 ROOTED 设备,我们可以像在模拟器中一样访问应用程序的数据.即使我想知道我们是否可以限制在模拟器中安装 apk.

I know that if it is ROOTED device, we can access the app's data same like in the simulator. Even though i would like to know whether we can restrict installing apk in simulators.

提前致谢

推荐答案

使用这个函数:

public static boolean isEmulator() {
    return Build.FINGERPRINT.startsWith("generic")
            || Build.FINGERPRINT.startsWith("unknown")
            || Build.MODEL.contains("google_sdk")
            || Build.MODEL.contains("Emulator")
            || Build.MODEL.contains("Android SDK built for x86")
            || Build.MANUFACTURER.contains("Genymotion")
            || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
            || "google_sdk".equals(Build.PRODUCT);
}

为此:

if (isEmulator()) {
   // emulator
} else {
   //not emulator
}

我的建议:

从 github 尝试 this.

try this from github.

容易检测的安卓模拟器

如何使用示例:

EmulatorDetector.with(this)
                .setCheckTelephony(true)
                .addPackageName("com.bluestacks")
                .setDebug(true)
                .detect(new EmulatorDetector.OnEmulatorDetectorListener() {
                    @Override
                    public void onResult(boolean isEmulator) {

                    }
                });

这篇关于如何限制 APK 不安装在 Android Emulator/Simulator 中,而是安装在真实设备中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆