I have an app in which i have to check whether my app got notification acccess or not for this i am using below mention code but this is throwing error on testing on device above api level 23. Pls help me to resolve this issue.
code:-
ContentResolver cr = getContentResolver();
String setting = "enabled_notification_listeners";
String permissionString = Settings.Secure.getString(cr, setting);
if (permissionString.contains("com.ermo.batt")) {
intent = new Intent(mContext, CNotificationHomeActivity.class);
startActivity(intent);
} else {
intent = new Intent(mContext, CNotificationManagerWalkThrough.class);
startActivity(intent);
}
error:-
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference