在 Android >= N 中,在设置中检查已授予 ACCESS_NOTIFICATION_POLICY 的应用程序
In Android >= N, check in Settings the apps that were granted ACCESS_NOTIFICATION_POLICY
在Android >= N 中,您需要用户使用以下代码手动允许通知策略访问。
Intent intent = new Intent(
android.provider.Settings
.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
startActivity(intent);
并放入清单中:
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
如何在我的 phone 上检查(目测)哪些应用程序被授予了权限?对于其他权限,我会转到“设置”>“应用程序”>“应用程序权限”,我会看到列出了所有可以使用它的应用程序的权限。但是我在界面中找不到(在Android 7),我可以在其中检查我的应用程序是否被授予了这种手动激活的权利。
您可以通过 API 调用 isNotificationPolicyAccessGranted
查看
NotificationManager nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (false == nm.isNotificationPolicyAccessGranted()) {
// Permissions were not granted, request for permission
}
您可以在“设置”>“声音和通知”>“通知访问”中直观地查看
在Android >= N 中,您需要用户使用以下代码手动允许通知策略访问。
Intent intent = new Intent(
android.provider.Settings
.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
startActivity(intent);
并放入清单中:
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
如何在我的 phone 上检查(目测)哪些应用程序被授予了权限?对于其他权限,我会转到“设置”>“应用程序”>“应用程序权限”,我会看到列出了所有可以使用它的应用程序的权限。但是我在界面中找不到(在Android 7),我可以在其中检查我的应用程序是否被授予了这种手动激活的权利。
您可以通过 API 调用 isNotificationPolicyAccessGranted
NotificationManager nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (false == nm.isNotificationPolicyAccessGranted()) {
// Permissions were not granted, request for permission
}
您可以在“设置”>“声音和通知”>“通知访问”中直观地查看