A
A
Artur_F2016-12-01 23:34:48
Android
Artur_F, 2016-12-01 23:34:48

How to know that an app has been closed from recent apps?

alarmManager fires, alarmActivity starts in receivere. If you close this activity (with the back button, for example), then the application itself will open, the last activity before it (back stack), but if the application was killed from recent apps, then nothing will open. I need to know in onDestroy of this AlarmActivity if the application was killed. If yes, then start MainActivity. Before android 5.0, you can look in activityManager.getRunningTasks, and if there is only one task with one activity, then we start MainActivity. But firstly, since version 5.0, getRunningTasks is considered obsolete, and it is not clear how to do it then, and secondly, something tells me that this is some kind of crooked solution. But I can't find anything. Tell me how to do it right. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
z0rgoyok, 2016-12-02
@Artur_F

onTaskRemoved

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question