Android Remote push notification- Set sound in repeat mode - android

I am able to play Remote Push Notification sound. But sound stops as soon as the sound file placed in raw folder plays completely.
I want to play sound in repeat mode till there is a user action.
Can't use FLAG_INSISTENT with notification builder as it is a remote notification.

Related

Push Notification sound not working in xiaomi

Notification sounds are getting suppressed due to Xiaomi sound settings. If Allow sound is toggled off notification sound will not be played. I want to show a popup to the user if this setting is disabled, but I am not able to fetch this setting using Notification manager or Android Manager. How can I fetch this os specific setting so that I can nudge the user?

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 : Playing audio file repeatedly on Push-Notification

I was wondering if there is a method to play an audio file on receiving a push notification. It's a short tone of 1second which I want to play for about 1minute at a gap of 10seconds each. Thus, playing the file 6 times in a minute.
This audio file is locally stored in the APP itself.
So, is there a way in which this can be done without running background services and when the app is closed?

notification sound not working when video is recording

In my app, the user have an option to record video. While the user is recording video, if the app triggers a local notification, the notification sound is missing.
But apps like Hangouts, System alarm etc. are able to trigger a notification with sound.
Tried setting notification priority to maximum, requesting audio focus but no luck.
notificationBuilder.setPriority(2);
notificationBuilder.setSound(soundUri, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
Is there a way to trigger a notification with sound, when camera recording is on ? Or is this the default behaviour ? Workarounds ?
Environment: Nexus 7, Android 6.0.1
PS: Whatsapp is able to generate notifications with sound on One Plus 2(Android 6.0.1) when video recording is on.

Notification Sound interrupting Music

I am trying to play Notification Sound without disturbing other Music playing
Notification Sound can be played by 2 ways
1) Played by OS itself via NotificationBuilder
Benifits:- Handle itself all the cases of not playing sound in Phone Calls and other cases as well
Problem:- When music is playing and notification comes, then it shifts audio focus from music to notification, there by lowering or silencing music depending on how that music player app has handled the loss in audio focus.
2) We play sound via our media Player whenever notification comes
A) Play on NOTIFICATION STREAM ---> works perfectly fine but gives probem of ducking when played via earphones
B) Play on SYSTEM STREAM
Benifits:- No shifting of audio focus, so no effect on music when notification comes
Problem:- We will have to handle other cases of not playing sound in Telephonic call and VOIP as well...and may be other not known cases as of now .
But I figured it that watsup is doing fine.
So don't know how it is doing it
Per the Android 5.0 behavior changes on notification sounds:
If you are currently adding sounds and vibrations to your notifications by using the Ringtone, MediaPlayer, or Vibrator classes, remove this code so that the system can present notifications correctly in priority mode. Instead, use Notification.Builder methods to add sounds and vibration.
Setting the device to RINGER_MODE_SILENT causes the device to enter the new priority mode. The device leaves priority mode if you set it to RINGER_MODE_NORMAL or RINGER_MODE_VIBRATE.
Previously, Android used STREAM_MUSIC as the master stream to control volume on tablet devices. In Android 5.0, the master volume stream for both phone and tablet devices is now unified, and is controlled by STREAM_RING or STREAM_NOTIFICATION.
As there is not a direct way to detect whether a device is in priority mode, you should always use the Notification.Builder/NotificationCompat.Builder methods to add sound to your notifications to ensure you meet the user's expectations.

Categories

Resources