'Android 11 bypass the permissions of "allow only while using the app"

I trying to develop an app that can take photos in the background. This app can prevent mobile phones from being stolen. If be stolen, the phone will send back photos and location. I started an android service to receive the command from the user. The service can call android-camera2 to take pictures. But the app I wrote doesn't work that It can only be allowed when it is used. Once the activity enters the background, it can't take photos. How can I solve this problem? I can modify the ROM of the android system. So are there any tips that can be provided? thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source