由于项目有需要用到判断用户是不是模拟器用户,在CPU、机型、唯一码等方法都不行的时候,还有一个方法就是拨号,或者再加上一些特征码。
但目前夜神和蓝叠都仍被判断为真机(莫非只能上光感了?)
public static boolean IsEmulator() { try { Activity m_activity = UnityPlayer.currentActivity; String url = "tel:" + "12345678910"; Intent intent = new Intent(); intent.setData(Uri.parse(url)); intent.setAction(Intent.ACTION_DIAL); // 是否可以处理跳转到拨号的 Intent boolean canResolveIntent = intent.resolveActivity(m_activity.getPackageManager()) != null; return Build.FINGERPRINT.startsWith("generic") || Build.FINGERPRINT.toLowerCase().contains("vbox") || Build.FINGERPRINT.toLowerCase().contains("test-keys") || Build.MODEL.contains("google_sdk") || Build.MODEL.contains("Emulator") // || Build.BOARD.equals("unknown") // || Build.BOOTLOADER.equals("unknown") || Build.MODEL.contains("Android SDK built for x86") || Build.MANUFACTURER.contains("Genymotion") || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic")) || Build.PRODUCT.equals("google_sdk") || ((TelephonyManager)m_activity.getSystemService(Context.TELEPHONY_SERVICE)) .getNetworkOperatorName().toLowerCase().equals("android") || !canResolveIntent; } catch (Exception e) { return false; } }