我正在使用以下简单代码来在DND期间请求更改铃声的权限。应用程序正在Android 6.0上进行测试。但是它会崩溃,并显示以下日志:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS }
这是我的代码:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!notificationManager.isNotificationPolicyAccessGranted()) {
startActivity(new Intent(ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS));
}
}
时,我会调用这个函数。
Intent
操作可能不被某些设备支持)。 - CommonsWare