Music player control in notification

You need to set a custom intent action, not the AudioPlayerBroadcastReceiver component class. Create a Intent with custom action name like this Intent switchIntent = new Intent(“com.example.app.ACTION_PLAY”); Then, register the PendingIntent Broadcast receiver PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 100, switchIntent, 0); Then, set a onClick for the play control , do similar custom action for other … Read more

How to set the app icon as the notification icon in the notification drawer

I know its bit late to answer here and also its already been answered, but I came here looking for an easy fix using firebase notifications. Someone like me visiting here can do the solution by recommended and easy way of firebase notification, which is simply adding meta-data in manifest. Reference <!– Set custom default … Read more

How to Schedule Notification in Android

NOT FOR USE IN OREO+ (edit) The answers above are good – but don’t consider the user’s potential to restart the device (which clears PendingIntent’s scheduled by AlarmManager). You need to create a WakefulBroadcastReceiver, which will contain an AlarmManager to schedule deliver a PendingIntent. When the WakefulBroadcastReceiver handles the intent – post your notification and … Read more

Notification passes old Intent Extras

You are sending the same request code for your pending intens. Change this: PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); To: PendingIntent contentIntent = PendingIntent.getActivity(context, UNIQUE_INT_PER_CALL, notificationIntent, 0); intents are not created if you send the same params. They are reused.

On Android 8.1 API 27 notification does not display

If you get this error should be paid attention to 2 items and them order: NotificationChannel mChannel = new NotificationChannel(id, name, importance); builder = new NotificationCompat.Builder(context, id); Also NotificationManager notifManager and NotificationChannel mChannel are created only once. There are required setters for Notification: builder.setContentTitle() // required .setSmallIcon() // required .setContentText() // required See example: private … Read more

Heads-up Notification – Android Lollipop

According to Notifications, you are required to set a vibrate or ringtone to make Heads-up work. However, here’s a quick hack that doesn’t require VIBRATE permission to produce a head-up notification: notificationBuilder.setPriority(Notification.PRIORITY_HIGH); if (Build.VERSION.SDK_INT >= 21) notificationBuilder.setVibrate(new long[0]); EDIT: Don’t abuse heads-up notification. See here for when to use heads-up notification: MAX: For critical and … Read more

Create Custom Big Notifications

Update due to API changes: From API 24 on, the Notification.Builder contains a setCustomBigContentView(RemoteViews)-method. Also the NotificationCompat.Builder (which is part of the support.v4 package) contains this method. Please note, that the documentation for the NotificationCompat.Builder.setCustomBigContentView states: Supply custom RemoteViews to use instead of the platform template in the expanded form. This will override the expanded … Read more