如何通过意图访问通知辅助功能页面?
How to access Notification Accessibility page via intent?
我正在构建一个需要通知辅助功能权限的 Android 应用程序。
我的想法是在应用程序首次启动时将用户带到通知辅助功能页面,我如何通过意图做到这一点?
要通过 Intent 打开 NotificationAccessSettingsActivity,您可以这样做:
startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
如果你想检查你可以使用的权限:
private boolean isNotificationServiceRunning() {
ContentResolver contentResolver = getContentResolver();
String enabledNotificationListeners =
Settings.Secure.getString(contentResolver, "enabled_notification_listeners");
String packageName = getPackageName();
return enabledNotificationListeners != null && enabledNotificationListeners.contains(packageName);
}
我正在构建一个需要通知辅助功能权限的 Android 应用程序。 我的想法是在应用程序首次启动时将用户带到通知辅助功能页面,我如何通过意图做到这一点?
要通过 Intent 打开 NotificationAccessSettingsActivity,您可以这样做:
startActivity(new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
如果你想检查你可以使用的权限:
private boolean isNotificationServiceRunning() {
ContentResolver contentResolver = getContentResolver();
String enabledNotificationListeners =
Settings.Secure.getString(contentResolver, "enabled_notification_listeners");
String packageName = getPackageName();
return enabledNotificationListeners != null && enabledNotificationListeners.contains(packageName);
}