Reputation: 401
I tried to display notification by this
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.front2).setContentTitle("WAKE ME UP!").setContentText(text);
Intent intent1 = new Intent(this.getApplicationContext(), MainActivity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingNotificationIntent);
NotificationManager mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(0, mBuilder.build());
BUT, currently, it's not show the text like other apps ( i mean: diplay text line by line on notifycation bar), my code is just display the icon con notifycation bar. If i want to see message, i have to open the notifycation dropdown.
Question: How can i do a notification like other apps
Thanks for all your help
Upvotes: 0
Views: 83
Reputation:
try this it will work mBuilder.setContentTitle("Notification Alert, Click Me!"); mBuilder.setContentText("Hi, This is Android Notification Detail!");
Upvotes: 1