Android 判断开发者选项开关是否打开
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED
近期需要用到判断Android手机系统开发者选项是否打开的, 遇事不决,先搜索下,一顿操作后发现都是使用adb调试(Settings.Global.ADB_ENABLED)是否打开来判断的,但是由于国内各大厂商对系统源码的定制化,部分手机会出现adb调试开启与否和开发者选项无关; 最后还是在源码内找到了控制开发者选项的开关 Settings.Global.DEVELOPMENT_SETTINGS_ENABLED
/**
* 开发者选项是否开启
*
* @return true 开启
*/
public static boolean isOpenDevelopmentSetting(Activity activity) {
boolean enableAdb = Settings.Secure.getInt(activity.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
return enableAdb;
}
/**
* usb调试是否开启
*
* @return true 开启
*/
public static boolean isUSBDebugSetting(Activity activity){
boolean enableAdb = Settings.Secure.getInt(activity.getContentResolver(), Settings.Global.ADB_ENABLED, 0) != 0;
return enableAdb;
}
|