调用隐式意图跳转至设置-应用详情界面以及跳转至设置-应用通知设置界面

1、调用隐式意图跳转至设置-应用详情界面:

Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 
intent.setData(Uri.fromParts("package", getPackageName(), null)); 
startActivity(intent); 

2、调用隐式意图跳转至设置-应用通知设置界面:

try { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 

//Android 8.0以上 
intent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); 
intent.putExtra(Settings.EXTRA_CHANNEL_ID, getApplicationInfo().uid);

 //Android 5.0 ~ Android 7.1 
intent.putExtra("app_package", getPackageName()); 
intent.putExtra("app_uid", getApplicationInfo().uid); 

startActivity(intent); } catch (Exception e)
{ e.printStackTrace(); 
 Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); 
intent.setData(Uri.fromParts("package", getPackageName(), null)); 
startActivity(intent); } 

需要注意,部分手机是会报异常的,如果报异常,则跳转至应用详情界面。

你可能感兴趣的:(笔记)