Reputation: 4595
I have got this simple code that issues a Notification.
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this)
.setSmallIcon(
R.drawable.ic_launcher)
.setContentTitle("Error deactivating Tracker")
.setContentText("Unable to send deactivation SMS");
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(0, mBuilder.build());
The notifications shows correctly on a 4.4.2 device, but it does not show on a 2.3.6 device.
I am using the NotificationCompat
so I suppose it should show.
What am I doing wrong?
Upvotes: 0
Views: 54
Reputation: 4595
Solved.
Apparently it wants a PendingIntent in any case,
so I added it:
PendingIntent pi = PendingIntent.getBroadcast(this, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this)
.setSmallIcon(
R.drawable.ic_launcher)
.setContentTitle("Error deactivating Tracker")
.setContentText("Unable to send deactivation SMS")
.setContentIntent(pi).setTicker("Error deactivating Tracker");
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(0, mBuilder.build());
Upvotes: 1