I have huawei phone and when I use foreground service on huawei its just stop the service. However, I found this solution ( https://stackoverflow.com/a/51726040/14446860 ). Because my app isn't enable in the protected apps on my huawei phone,the service stop.
My question is, How can I broadcast this setting when I am asking the user to enable protected app? Do I have to ask the user every time even he enable it ?
To prevent malicious applications from running in the background and associated startup, your phone's memory and power consumption increase sharply. By default, the EMUI does not allow related apps to be kept alive or started in the background. However, you can manually keep the apps alive on the mobile phone so that the apps can be started or automatically started in the background. The apps take effect after restart.
If the application needs to be allowed in the background due to application scenarios, it is recommended that a message be displayed when the application is started for the first time after installation, instructing you to manually keep the application alive.
To do this, choose Phone Manager > App Startup Management > Disable Automatic Management > Allow Auto Startup or Allow Background Activities.
The EMUI allows users to switch from the app to the app startup management page, but does not provide an interface for querying whether an app is kept alive in the background.
It is recommended that you display a prompt rather than jump.
When the app is started for the first time, a message is displayed, instructing you to manually keep the app alive in the background.