Recently some Conf Call Dialer users asked to add notifications to the application, so (since it seems to be a good idea) I've spent few hours implementing them in the app. Everything went smoothly, except of one rather funny problem, after executing NotificationManager.notify, notifications were not showing up and I was getting all the time the following warning in the LogCat (12345 is the id assigned to the notification):
notify: id corrupted: sent 12345, got back 0
My code seemed to be rather simple (mostly copy paste from the javadoc, with some app specific logic added):
Googling didn't help, so I compare the code to the standard and the only difference was lack of the small icon (well, I didn't have it at this time so I decided I will skip it). And guess what - without a small icon the notification will NOT work and the only message you'll get is the "id corrupted" mentioned above.
The following code works already:
notify: id corrupted: sent 12345, got back 0
My code seemed to be rather simple (mostly copy paste from the javadoc, with some app specific logic added):
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this). setContentTitle(event.subject).setContentText(event.timeFrom + " " + additionalText); // ... NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(notificationId, mBuilder.build());
Googling didn't help, so I compare the code to the standard and the only difference was lack of the small icon (well, I didn't have it at this time so I decided I will skip it). And guess what - without a small icon the notification will NOT work and the only message you'll get is the "id corrupted" mentioned above.
The following code works already:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this). setContentTitle(event.subject).setContentText(event.timeFrom + " " + additionalText).setSmallIcon(R.drawable.ic_action_search); // ... NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(notificationId, mBuilder.build());
Comments
Post a Comment