Use of the Android notification bar and android notification bar
Key code and click event in which the app sends a notification message to the notification bar:
Package com. example. communications; import android. OS. bundle; import android. app. activity; import android. app. notification; import android. app. icationicationmanager; import android. app. pendingIntent; import android. content. context; import android. content. intent; import android. support. v4.app. notificationCompat; import android. view. menu; import android. view. view; public class MainActivity extends Activity {public Static final int notifi_id = 0x1; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main);} public void sendNotifi (View v) {icationicationcompat. builder builder = new NotificationCompat. builder (this); builder. setSmallIcon (R. drawable. ic_launcher); builder. setContentTitle ("You have a new message"); builder. setContentText ("Happy New Year! "); Builder. setTicker ("New message"); builder. setDefaults (Notification. DEFAULT_ALL); // builder. setAutoCancel (true); Intent intent = new Intent (this, Second. class); PendingIntent pi = PendingIntent. getActivity (this, 0, intent, PendingIntent. FLAG_UPDATE_CURRENT); builder. setContentIntent (pi); // builder. setOngoing (true); // resident Notification // create an object Notification n = builder. build (); // obtain the system's notification manager, and then send the notification NotificationManager nm = (icationicationmanager) getSystemService (Context. NOTIFICATION_SERVICE); nm. Y (notifi_id, n );}}