Closed AlanMTuring closed 4 months ago
@AlanMTuring This is probably due to the activity being backgrounded. What happens if instead of passing the activity context to the Voice.Connect, you passed the application context?
In our production app, we are already passing in the application context to the voice connect and into the AudioSwitch creation, and the problem is still there.
With the quickstart, I edited the code in VoiceActivity.handleCallRequest()
so that Voice.connect
takes in the application context and in VoiceActivity.answer()
so that activeCallinvite.accept()
also takes in the application context. After those changes, i was still able to reproduce the issue.
@AlanMTuring ok, My next question is are you integrating with the ConnectionService API? If not, you shouldn't be using the FOREGROUND_SERVICE_PHONE_CALL and instead should use FOREGROUND_SERVICE_MICROPHONE.. For more info look here..
Continue microphone capture from the background, such as voice recorders or communication apps.
https://developer.android.com/about/versions/14/changes/fgs-types-required#microphone
Thanks, that solved it!
Just to note, we have two foreground services, an IncomingCallNotificationService and an ActiveCallNotificationService. The incoming call is still a FOREGROUND_SERVICE_PHONE_CALL
and at least in our code is needed as such to show the incoming call notification. Changing the active call service to FOREGROUND_SERVICE_MICROPHONE
solved the audio issue while the app is in the background and still shows the proper notification 👍
Describe the bug Our production app targets Android 14 and uses the AudioSwitch. When users are on Android 14 and either lock their screen or put our app in the background, they can hear audio come through but audio input no longer works.
I've also been able to reproduce on the voice quickstart by bumping the targetSdk to 34. Doing so required the following changes to the project:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL"/>
toconnection_service/AndroidManifest.xml
android:foregroundServiceType="phoneCall"
to IncomingCallNotificationService inconnection-service/AndroidManifest.xml
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
toonRequestPermissionsResult(...)
inVoiceActivity.java
Similar to an older issue, but new for Android 14.
To Reproduce Steps to reproduce the behavior:
Expected behavior Locking screen or putting app in background with the foreground service started should keep the input audio working
Actual behavior Locking screen or putting app in background causes the input audio to stop working
Application Logs
AudioSwitch Version
Android Device (please complete the following information):
Screenshots N/A
Additional context N/A