Android Emulator Crashes Claiming “Null Notification”
-
28-10-2019 - |
Question
I'm running into a bug in the android code described here:
http://code.google.com/p/android/issues/detail?id=9840
However I'm extremely confused by what they are saying for example:
I also sent a NULL notification by mistake, and crashed the system process. My code was:
int icon = R.drawable.notification_icon; CharSequence tickerText = "Filter Active"; long when = System.currentTimeMillis(); Notification n = new Notification(icon, tickerText, when); startForeground(startId, n);
from a service.
I don't understand why he's saying that he's sending a null notification when n is clearly being instantiated and passed to the startForeground service method. This is almost exactly what my code looks like and I can't find any explanation as to why it's wrong or what is the proper way.
Solution
Found it.
I agree with the sentiments expressed here. Completely unacceptable on all counts. Lack of documentation, ridiculous default behavior and a blatent design flaw which crashes the entire OS.
http://code.google.com/p/android/issues/detail?id=930
Essentially the setLatestEventInfo
method must be called for the notification to be valid.