摘要:booleaneableAdb=(Settings.Secure.getInt(getContentResolver(),Settings.Secure)。启用ADB_,0)˃0);//如果(enableAdb){ToastUtil.showShort(“adb调试模式已打开”);}否则{startDevelopmentActivity();//跳转到开发
boolean enableAdb = (Settings.Secure.getInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0) > 0);//判断adb调试模式是否打开
if (enableAdb) {
ToastUtil.showShort("adb调试模式已经打开");
} else {
startDevelopmentActivity();//跳转到开发者选项界面
}
/*** 打开开发者模式界面
*/
private voidstartDevelopmentActivity() {
try{
Intent intent = newIntent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
startActivity(intent);
} catch(Exception e) {
try{
ComponentName componentName = new ComponentName("com.android.settings", "com.android.settings.DevelopmentSettings");
Intent intent = newIntent();
intent.setComponent(componentName);
intent.setAction("android.intent.action.View");
startActivity(intent);
} catch(Exception e1) {
try{
Intent intent = new Intent("com.android.settings.APPLICATION_DEVELOPMENT_SETTINGS");//部分小米手机采用这种方式跳转
startActivity(intent);
} catch(Exception e2) {
}
}
}
}