/* * 检查是否是模拟器 * */ public class SimulatorUtils { public static boolean isSimulator(Context context) { if(notHasBlueTooth()||notHasLightSensorManager(context)||isFeatures()||checkIsNotRealPhone()){ return true; }else{ return false; } } /* *用途:判断蓝牙是否有效来判断是否为模拟器 *返回:true 为模拟器 */ public static boolean notHasBlueTooth() { BluetoothAdapter ba = BluetoothAdapter.getDefaultAdapter(); if (ba == null) { return true; } else { // 如果有蓝牙不一定是有效的。获取蓝牙名称,若为null 则默认为模拟器 String name = ba.getName(); if (TextUtils.isEmpty(name)) { return true; } else { return false; } } } /* *用途:依据是否存在光传感器来判断是否为模拟器 *返回:true 为模拟器 */ public static Boolean notHasLightSensorManager(Context context) { SensorManager sensorManager = (SensorManager) context.getSystemService(context.SENSOR_SERVICE);
Android 判断App运行在模拟器还是真机上的最终解决方案-2019工具类
最新推荐文章于 2024-05-12 03:12:22 发布