private Notification createNotification() {
// PendingIntent that will start your application's MainActivity
Intent intent = new Intent(context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// On Oreo and above, you must create a notification channel
String channelId = "channel-id";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "Channel name", NotificationManager.IMPORTANCE_LOW);
channel.setShowBadge(false);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
return new NotificationCompat.Builder(context, channelId)
.setContentTitle(context.getString(R.string.app_name) + " is running")
.setContentText("Touch to open.")
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher)
.setPriority(NotificationCompat.PRIORITY_MIN)