How to start background service on BOOT_COMPLETED event in Android?

Viewed 79

I've developed an application which start a foreground service and that service is implemented SensorEventListener. If onSensorChanged or onAccuracyChanged called it broadcast an intent. This forground service is started on BOOT_COMPLETED event and it should not be killed until user stops it.

Now customer requests that foreground service notification should not be displayed. I tried to make it as a background service. but Android system does not allow to start background service on BOOT_COMPLETED event.

What is the best way to start background service on BOOT_COMPLTED event and register for SensorEventListener. This Service should be run always until user stop it.

minSdkVersion 26
targetSdkVersion 30

Thank you

0 Answers
Related