Android 12+: Microphone stops in WebRTC app within a WebView when screen is locked or user switches apps

26 Views Asked by At

I'm developing a WebRTC voice calling app for Android using PeerJS, where all the PeerJS code runs within a WebView inside my CallScreen activity. The calling functionality works flawlessly. However, I've encountered an issue specific to Android 12 and higher devices: the microphone stops functioning as soon as the screen is locked or the user navigates to another app.

I've researched this extensively, and most suggestions online recommend using a Foreground service to record audio. Unfortunately, this isn't feasible in my scenario because I'm trying to access the microphone from a WebView within an activity.

Is there any workaround or solution to resolve this microphone issue on Android 12+ devices while still operating within the constraints of a WebView within an activity? Any insights or alternative approaches would be greatly appreciated. Thank you.

0

There are 0 best solutions below