You must call the build () method after you finish describing your notification. See the Android link for an example.
Basically, you should change your code to the following:
Context context = getApplicationContext(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context ) .setSmallIcon(R.drawable.ic_launcher); Intent intent = new Intent( context, MainActivity.class); PendingIntent pIntent = PendingIntent.getActivity(context, mID , intent, 0); builder.setContentIntent(pIntent); NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notif = builder.build(); mNotificationManager.notify(mID, notif);
Note This code allows you to show the icon in the notification panel. If you want it to be saved there, you will need to use FLAG_ONGOING_EVENT
source share