Android O : Notification channel for Incoming call - android

Introduction of notification channel allow many apps to remove their notification settings in app and redirect to device settings. Which is quite easy for developers as the framework itself will handle notification sounds.
Incoming call ringtones can be played via Ringtone manager or Media player. We cant play incoming call ringtone using notification because notification sound stops when the notification tray is opened.
Initially i created notification channel with IMPORTANCE_LOW so that there is no sound for incoming call notifications. There may be situation where user can assign sounds to incoming call notification where both sounds are played (sound set by notification channel and Incoming call ringtone which is handled by app).
This is a big problem for all calling apps. Can any one have solution for it ?

Related

Two notifications from MediaSessionCompat

My app can play music from the internet. For control, I use a push notification with buttons for pause/play and rewind. I create it via NotificationCompat Builder and set the MediaStyle. On the lock screen, MediaSessionCompat displays a full-screen notification for monitoring. But there is also a duplicate of the first notification. Because of this, I have two notifications on the lock screen.
Perhaps the MediaSession itself should hide the notification by its id or channel? I tried setting VISIBILITY_SECRET to the channel and notification, but it also displayed on the lock screen.
This may be behavior specific to your phone; I would first start by checking what the behavior is on an emulator.
Perhaps you'd like to compare how you're registering your MediaSession in the notification against the Universal Android Music Player Sample. In particular, check if you've set the MediaSession token with the MediaStyle notification using setMediaSession(); you can find how this is accomplished inside UAMP inside UampNotificationManager.

Stop overlapping Android Audio Notifications

When using FCM Notification Channels - it is no longer possible to change the Notification Sound when a notification arrives (using SetSound()). This is causing me a problem when my app receives a notification while the audio of a previous notification is playing. Our notification sound bites are 2-3 seconds long each, and when the second notification arrives, it cuts the first notification's audio off.
Instead of delaying the second notification from displaying, I would like for the second notification to display, but not play any audio. Is this possible?
I don't think you have that level of control over how Android displays/plays incoming notification messages.
The only approach I can think of is taking full control of the display of the messages in your own application code, by using data messages instead of notification messages.
Reminder: Firebase Cloud Messaging has two message types: notification messages, and data messages. Notifications messages are automatically handled/displayed by the OS when your app is not active, while data messages are always delivered to your application code.
From within your application code, you can then use the Android notification API to build the exact display of the message that you want, and display it exactly when you want it (within the notification settings of the user of course).

Android play ringtone using notification sounds in loop

I have created a notification channel and added sound attributes to it.
The issue I am facing is that I am not able to loop the notification sound until the notification has been cancelled. I am using the flag FLAG_INSISTENT, with the NotificationBuilder, which as per the documentation, does the following -
Bit set in the Notification flags field if the audio will be repeated until the notification is
cancelled or the notification window is opened.
This flag plays the sound in the loop but once notification window is opened(the notification panel is dragged down) the notification sound stops. Is there any alternative way to play the ringtone until the notification has been cancelled.
PS- I have explored other options such as MediaPlayer (which requires storage permission to play ringtone in external storage) and Ringtone object(this has the function of setLooping() which was added in API 28 and no alternative for lower SDKs)

Android push notification stop repeating sound on activity resume

I am implementing an app that receive push notifications. I have used flag Notification.FLAG_INSISTENT to continuously play sound until user drag notification panel. But I want to stop the sound on app resume rather than on dragging notification panel.
According to documentation, for notifications with FLAG_INSISTENT audio will be repeated until the notification is cancelled or the notification window is opened.
So when you resume your activity you can cancel your notification. if you want it to stay in the notification window, then redisplay it again without sound and the insistent flag.

Android - how to programatically set notification sound for future push notifications sent by FCM

My server is able to send FCM push notifications to my Android app users. The notifications are successfully delivered with default notification sound.
However, I want the app user to select sound from Ringtone Picker in the Preference screen.
I have been able to show Ringtone Picker in the Preference screen, but I don't know how to set the selected sound URI for future push notifications
So that when the future push notification of this app is received, the sound that user selected, should be played.
Please advice
Try using this? I assume in your app you are dealing with this class and library.
https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setSound(android.net.Uri)

Categories

Resources