Notification |
Hello guys,
When we develop an android app with target API level 23 means you can't create Notification like in API below 23... For that you have to use Notification.Builder......
On such situation you will use this coding to generate notification for your app...
It works for me and i'll hope that same for you.....
Code to generate Notification:
Notification.Builder nb = new Notification.Builder(context);
nb.setSmallIcon(android.R.drawable.stat_notify_more);
nb.setContentTitle("Notification");
nb.setContentText("Now Generated");
nb.setTicker("New Notification");
Intent i = new Intent(); /*if you want to start any activity by clicking the notification use it like a normal intent to call an activity*/
i.putExtra("eid",eid);
PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
nb.setContentIntent(pi);
Notification n = nb.getNotification();
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(0, n);
Thanks for view my Blog...
If you have any queries leave it as a comment plz....
No comments:
Post a Comment