flutter-plugins icon indicating copy to clipboard operation
flutter-plugins copied to clipboard

[Notifications]

Open bardram opened this issue 4 years ago • 2 comments

Device / Emulator and OS

Please complete the following information for each phone and/or emulator you're experiencing this bug on:

  • Device: Samsung
  • OS: Android 11

Describe the bug

There is a null pointer exception in the dk.cachet.notifications.NotificationListener:

E/AndroidRuntime(23308): FATAL EXCEPTION: main
E/AndroidRuntime(23308): Process: dk.cachet.notifications_example, PID: 23308
E/AndroidRuntime(23308): java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
E/AndroidRuntime(23308): 	at dk.cachet.notifications.NotificationListener.onNotificationPosted(NotificationListener.java:40)
E/AndroidRuntime(23308): 	at android.service.notification.NotificationListenerService.onNotificationPosted(NotificationListenerService.java:375)
E/AndroidRuntime(23308): 	at android.service.notification.NotificationListenerService$MyHandler.handleMessage(NotificationListenerService.java:2166)
E/AndroidRuntime(23308): 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(23308): 	at android.os.Looper.loop(Looper.java:246)
E/AndroidRuntime(23308): 	at android.app.ActivityThread.main(ActivityThread.java:8512)
E/AndroidRuntime(23308): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(23308): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/AndroidRuntime(23308): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

To Reproduce

Running the example app. Turning the screen off/on.

bardram avatar Aug 03 '21 14:08 bardram

Running into the same problem, I mainly noticed the inbuild Games app from OxygenOS triggers this null pointer exception when a Game is started. Even when removing all games the null pointer happens sooner or later, so it's not exclusively a Games issue .

Lynnsanee avatar Oct 06 '21 22:10 Lynnsanee

Seems no one is responding. I had this issue before and had to open the package in \AppData\Local\Pub\Cache\hosted\pub.dartlang.org\notifications-2.0.1\android\src\main\java\dk\cachet\notifications then update the NotificationListener.java file. I changed the line intent.putExtra(NOTIFICATION_MESSAGE, text.toString()); to intent.putExtra(NOTIFICATION_MESSAGE, text==null?"":text.toString()); You might have to change the line before this too in the same way if you still get errors.

For me this error showed up everytime an email notification came through for gmail

Scylla2020 avatar Jan 04 '22 08:01 Scylla2020