This tutorial demonstrates how to send notifications from an Android app. -------------------- 1. MainActivity.java -------------------- import android.app.Activity; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends Activity { Button btn; String CHANNEL_ID = "10001"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn = (Button)findViewById(R.id.button1); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createNotificationChannel(); Notification.Builder builder = new Notification.Builder(MainActivity.this); builder.setChannelId(CHANNEL_ID); Intent MyIntent = new Intent(Intent.ACTION_VIEW); PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),0,MyIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.setSmallIcon(R.drawable.notification_template_icon_bg) .setContentTitle("Hello World Notification") .setContentText("Hi, this is the notification details!") .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = builder.getNotification(); notificationManager.notify(R.drawable.notification_template_icon_bg, notification); } }); } private void createNotificationChannel() { // Create the NotificationChannel, but only on API 26+ because // the NotificationChannel class is new and not in the support library if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = "Channel Name"; String description = "Channel Descripton"; int importance = NotificationManager.IMPORTANCE_DEFAULT; NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); channel.setDescription(description); // Register the channel with the system; you can't change the importance // or other notification behaviors after this NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } } } -------------------- 2. activity_main.xml --------------------