Skip to content Skip to sidebar Skip to footer

Keep Background Service Running After Killing An Application

I have developed an android application which runs background service, I need the service to stay alive even if the application is killed by user or for some reason. I have impleme

Solution 1:

Developer's documentation says you can achieve this behaviour by using the attribute:

 android:isolatedProcess="true"

OR

 android:stopWithTask="false"

OR Using Both

START_STICKY will be ignored if the resources are scare.

By using android:stopWithTask="false" wont allow tasks to be closed even app is destroyed

eg:

<service
        android:name=".ServiceName"
        android:process=":MYPROCESS"
        android:isolatedProcess="true"
        android:stopWithTask="false">
            <intent-filter>
                 <action android:name="PackageName.ServiceName" />
            </intent-filter>
  </service>

Post a Comment for "Keep Background Service Running After Killing An Application"