Post a notification to be shown in the status bar. If a notification with the same id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information.
Parameters:
id - An identifier for this notification unique within your application.
notification - A Notification object describing what to show the user. Must not be null.
1.In the MainActivity.java file, Get a Reference to NotificationManager
3. Create an Intent for an Activity. Set the Activity name to MainActivity.
4. Set a PendingIntent with getActivity, using a PendingIntent named myPendingIntent. This PendingIntent will be fired if a user clicks the Notification item.
5. Deprecated: Set the Title and Text of a Notification. Use the Context named myContext. Set the title to "This is the title." Set the text to "This is my Text". Set the PendingIntent to myPendingIntent.
6. Add the below line to the onCreate method. This will post the notification to status bar.4. Set a PendingIntent with getActivity, using a PendingIntent named myPendingIntent. This PendingIntent will be fired if a user clicks the Notification item.
5. Deprecated: Set the Title and Text of a Notification. Use the Context named myContext. Set the title to "This is the title." Set the text to "This is my Text". Set the PendingIntent to myPendingIntent.
myNotificationManager.notify(1, myNotification);
7. Compile and run!