Access to the Microphone
in the background is stopped in Android 11
. There are only 3 options, Allow when in-use, Allow once, and Deny.
How to make the app get access to the microphone in the background all the time in Android 11
? Is there any workaround?
Now we have to specify a type for our foreground service (https://developer.android.com/guide/components/foreground-services#types):
<manifest>
...
<service ...
android:foregroundServiceType="camera|microphone" />
</manifest>
But in some cases our foreground service can't still access camera or microphone even if we specified android:foregroundServiceType
:
If a foreground service was started while app was in background (wasn't visible to a user - no visible activities), for example on device boot (BOOT_COMPLETED
) broadcast, then such service can't start using camera, microphone
If a foreground service was started while app was in foreground (was visible to a user - some visible activity) then such service can start using camera, microphone
Info from: https://developer.android.com/guide/components/foreground-services#bg-access-restrictions
My issue Camera2 cameraManager.openCamera exception from time to time on some devices
The new Android Developer Policy restricts access to Microphone and Camera in the background.
Using Accessibility Service
one can still use the feature in the background. However, the notification will always be on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With