Join Slack
Powered by
Is there a way to know when an application has bee...
# android
j
Julius Marozas
08/23/2020, 9:28 PM
Is there a way to know when an application has been closed (swiped away in android recents screen)? I have a foreground service which should survive process death but would stop when the application has deliberately been closed by a user.
i
Ian Lake
08/23/2020, 10:04 PM
Sounds like you're looking for
https://developer.android.com/reference/kotlin/android/app/Service#ontaskremoved
👍 4
s
Sergey Y.
08/23/2020, 11:35 PM
+1 to onTaskRemoved. FYI, it doesn't work on Xiaomi devices with MIUI skin.
i
Ian Lake
08/24/2020, 12:28 AM
That's because they force stop your whole app when you swipe away the task, killing everything as per
https://dontkillmyapp.com/xiaomi
s
Sergey Y.
08/24/2020, 7:11 AM
@Ian Lake
thanks, I know it. I have struggled with similar things in android for 7 years.
123
Views
Open in Slack
Previous
Next