I created Notification
in onStartCommand
of my Service
class to run a foreground service.
In previous versions of Android (version < 6.0) the service keeps running and the Notification
can not be removed even if I kill the app from the recent apps menu. I'm also using BOOT_COMPLETED
intent filter for my BroadCastReceiver
so that my service starts as my device restarts. Everything is working fine in Lollipop and previous versions. But when I tested in my Marshmallow device, when I clear my ram from recent app, the foreground service is also killed and the Irremovable Notification also being removed. As a result my app stops working. Service does not start when the device restarts either.
Is it causing by the famous DOZE MODE implemented in Android 6.0 and Higher ? Or there is something else ? Please help me someone ? I asked for help earlier but couldn't resolve the problem.
you have to add process attribute in manifest
<service
android:name=".YourServiceName"
android:process=".process"
android:enabled="true"
android:exported="true"></service>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.