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.