我正在尝试根据本教程在我的应用程序中实现 NotificationListenerService:http ://www.kpbird.com/2013/07/android-notificationlistenerservice.html ,但是在调用 getActiveNotifications 时出现 NullPointerException。
Caused by: java.lang.NullPointerException
at android.os.Parcel.readException(Parcel.java:1437)
at android.os.Parcel.readException(Parcel.java:1385)
at android.app.INotificationManager$Stub$Proxy.getActiveNotificationsFromListener(INotificationManager.java:500)
at android.service.notification.NotificationListenerService.getActiveNotifications(NotificationListenerService.java:149)
at com.rootsoft.rsnotificationservice.RSNotificationService.activeNot(RSNotificationService.java:85)
at com.rootsoft.rsnotificationservice.RSNotificationService.access$0(RSNotificationService.java:81)
at com.rootsoft.rsnotificationservice.RSNotificationService$1.onReceive(RSNotificationService.java:105)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:763)
... 9 more
我正在向应该生成所有通知列表的服务发送广播:
private void activeNot () {
List l = new List();
l.Initialize();
for (StatusBarNotification sbn : getActiveNotifications() ) { <---- Error happens here
l.Add(sbn);
}
Log.i("B4A", "List created.");
}
}