3

I need to detect application process kill to run some clean up tasks on server side.

The solutions which is mentioned on popular questions are no longer works on Android 8 or later. Is there a way to detect application kill on Android 8 or later?

Pre-Android 8 solutions:

fthdgn
  • 1,339
  • 1
  • 13
  • 18

1 Answers1

0

You could use same solutions you linked, but starting from Oreo a SERVICE should be started as FOREGROUND_SERVICE or it will be killed withing 5 seconds from the System. So you can reuse 90% of previous code but you need to do changes according to new Oreo requirements.

However if the App is killed from "Android Settings --> Apps" page by selecting the "Terminate" button, even all Background Services are killed in the same time, so if this case occurs those methods will not work anymore.

emandt
  • 2,547
  • 2
  • 16
  • 20