//// Step 1: Obtain icationicationmanagernotificationmanager nm = (NotificationManager) getSystemService (Context. NOTIFICATION_SERVICE); // Step 2: Define icationicationintent intent = new Intent (this, OtherActivity. class); // PendingIntent is the IntentPendingIntent pi = PendingIntent. getActivity (this, 0, intent, PendingIntent. FLAG_CANCEL_CURRENT); Notification notification = new Notification. builder (this ). setContentTitle ("title "). setContentText ("text "). setSmallIcon (R. drawable. ic_launcher ). setContentIntent (pi ). build (); notification. flags = Notification. FLAG_NO_CLEAR; // Step 3: Start the notification bar. The first parameter is the unique identifier of a notification, nm. Y (0, notification); // disable notification // nm. cancel (0 );
For more complex functions, You can query relevant api documentation.