How to check programmatically if user turn off push notification in app settings? Can I open app settings intent directly from the app to prompt user to turn it on?
you can't access this property unless you declare the system process or have root permission, first you can see the permission of file: /data/system/notifycaiton_policy.xml: -wr------。
In aother way, see the source code of: /android/4.2/frameworks/base/services/java/com/android/server/NotificationManagerService.java. in api: public void setNotificationsEnabledForPackage(String pkg, boolean enabled), there will check the caller's UID whether be Process.SYSTEM_UID:
void checkCallerIsSystem() {
int uid = Binder.getCallingUid();
if (UserHandle.getAppId(uid) == Process.SYSTEM_UID || uid == 0) {
return;
}
throw new SecurityException("Disallowed call for uid " + uid);
}