我有一个应用程序,我必须检查我的应用程序是否收到通知,因为我使用下面提到的代码,但这是在api级别23上的设备上测试时出错。请帮我解决这个问题
代码: -
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);
}
错误: -
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference