String channelId = "default"; String title = context.getString(R.string.app_name); PendingIntent pendingIntent = PendingIntent.getActivity(context, 101, intent, PendingIntent.FLAG_UPDATE_CURRENT); // Foreground Notification ContextNotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId); Notification notification = notificationBuilder .setContentTitle(title) .setSmallIcon(android.R.drawable.btn_star) .setContentText("Alarm Counter") .setAutoCancel(true) .setContentIntent(pendingIntent) .setWhen(System.currentTimeMillis()) .build(); // Notification Channelif (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(channelId, title, NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription("Silent Notification"); channel.setSound(null, null); channel.enableLights(false); channel.setLightColor(Color.BLUE); channel.enableVibration(false); notificationManager.createNotificationChannel(channel); } startForeground(1, notification);
Hello and welcome to my Online study Blog. My name is Sanjay Singh and I am a blogger from India. If you are looking for information about online android development code , you have come to the right place. I have failed and I have been successful. This is my story.
Saturday, 20 October 2018
Nougat and oreo notification
Labels:
Android
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment