Home > Enterprise >  Start camera from foreground service if START_ACTIVITIES_FROM_BACKGROUND granted for the app (Androi
Start camera from foreground service if START_ACTIVITIES_FROM_BACKGROUND granted for the app (Androi

Time:12-20

My app process starts a foreground service when it receives BOOT_COMPLETED action

That service is for video recording (dashboard camera app) which uses camera and microphone.

To start a camera from a foreground service on Android 11 one of the conditions must be met (Exemptions from the restrictions to starting a camera/micro from a foreground service) enter image description here

https://developer.android.com/guide/components/foreground-services#test-restrictions

Anyway I as I mentioned before I have a method to check if the camera is allowed to be used for my app process before I open it

There are so many problems with that. Phones (of different manufactures) behave differently. Some unexpected exceptions during using camera.

So basically even if everything was taken into account, for example, a user started the launch activity of the app, which starts the foreground service, in this case foreground is now allowed to use the camera, but still some issues with opening camera can happen while the same foreground service was running for some time

CodePudding user response:

So do I have now START_ACTIVITIES_FROM_BACKGROUND permission granted or not?

No. That permission is defined in the framework as:

    <permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"
        android:protectionLevel="signature|privileged|vendorPrivileged|oem|verifier" />

To hold it, you need to request it in the manifest of your app, and your app needs to be part of the firmware build (or be installed on the privileged partition by a user of a rooted device).

If I understood correctly to get START_ACTIVITIES_FROM_BACKGROUND permission I must have one of the conditions must be met (Exemptions from the restrictions to starting activities from the background) https://developer.android.com/guide/components/activities/background-starts#exceptions

That page does not refer to that permission.

  • Related