如何阻止我的应用程序在Bluestacks模拟器上运行?

问题描述 投票:0回答:1

我试图阻止我的应用程序在模拟器上运行,但是我不知道如何阻止它在Bluestacks上运行。这是我尝试过的。

            || Build.FINGERPRINT.startsWith("generic")
            || Build.FINGERPRINT.startsWith("unknown")
            || Build.HARDWARE.contains("goldfish")
            || Build.HARDWARE.contains("ranchu")
            || Build.MODEL.contains("google_sdk")
            || Build.MODEL.contains("Emulator")
            || Build.MODEL.contains("Android SDK built for x86")
            || Build.MANUFACTURER.contains("Genymotion")
            || Build.PRODUCT.contains("sdk_google")
            || Build.PRODUCT.contains("google_sdk")
            || Build.PRODUCT.contains("sdk")
            || Build.PRODUCT.contains("sdk_x86")
            || Build.PRODUCT.contains("vbox86p")
            || Build.PRODUCT.contains("emulator")
            || Build.PRODUCT.contains("simulator")
            || Build.MANUFACTURER.contains("CMDC")
            || Build.MANUFACTURER.contains("BlueStacks")
android android-emulator
1个回答
0
投票
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String networkOperator = tm.getNetworkOperatorName();
if("Android".equals(networkOperator)) {
    // Emulator
}
else {
    // Device
}

仿真器没有SIM卡,因此执行上述代码时它将返回空字符串:“”。 Android始终以网络运营商的身份返回“ Android”,这可能会有所帮助。

J J Kiim回答

参考-

https://stackoverflow.com/a/6577813/9024123

https://stackoverflow.com/a/35896310/9024123

© www.soinside.com 2019 - 2024. All rights reserved.