twilio / voice-quickstart-android

Quickstart app for the Voice Android SDK
https://www.twilio.com/docs/api/voice-sdk/android/getting-started
MIT License
184 stars 140 forks source link

How do I change the incoming call notification sound when the app is in background or device is locked? #411

Closed KodyKendall closed 3 years ago

KodyKendall commented 3 years ago

When the device is locked, and an incoming call is coming through, it just plays the default notification sound. Obviously, it doesn't repeat like the YouTube video does, it's just a single notification then stops, which doesn't sound like a ringtone and is confusing my users.

How can I get it to play the default ringtone sound, or the sound that plays when the app is open? The res/raw/incoming.wav sound?

I've tried adding:

       callInviteChannel.setSound(Uri.parse("android.resource://com.twilio.voice.quickstart/" + R.raw.incoming), null);

and

        Uri ringTone = Uri.parse("android.resource://com.twilio.voice.quickstart/" + R.raw.incoming);

        Notification.Builder builder =
                new Notification.Builder(getApplicationContext(), channelId)
                        .setSmallIcon(R.drawable.ic_call_end_white_24dp)
                        .setContentTitle(getString(R.string.app_name))
                        .setContentText(text)
                        .setCategory(Notification.CATEGORY_CALL)
                        .setExtras(extras)
                        .setAutoCancel(true)
                        .addAction(android.R.drawable.ic_menu_delete, getString(R.string.decline), piRejectIntent)
                        .addAction(android.R.drawable.ic_menu_call, getString(R.string.answer), piAcceptIntent)
                        .setFullScreenIntent(pendingIntent, true)
                        .setSound(ringTone);

But neither are working. Any other thoughts or areas you can point me in the right direction?

KodyKendall commented 3 years ago

I used a development branch where they had implemented ConnectionService, and continued implementation to take advantage of the native UI and default ring sound.

liyamahendra commented 2 years ago

@KodyKendall I had a similar requirement and resolved this by adding the below line to setCallInProgressNotification to the else part where app is not visible.

SoundPoolManager.getInstance(IncomingCallNotificationService.this).playRinging();