Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why my App still visible in task manager after finishing it

Tags:

android

I'm calling finish() if a certain condition was met. However, even after finish() if i hold the home button i can still see my app there. If killing the process is not a desirable option, what should I do?

This is where i'm calling finish():

    protected void onStart() {
.............
if(today.equals("..."))
finish();

    };

I know that finish will finish the activity but why is it still visible in the task manager? I've finished it.

like image 280
ARMAGEDDON Avatar asked Jun 06 '13 16:06

ARMAGEDDON


People also ask

Where is task manager app?

Simply press Ctrl+Shift+Escape on your keyboard to bring up Task Manager. On the keyboard, press "Ctrl + Alt + Delete," you will see few options. To open Task Manager, select "Task Manager." To open Task Manager, right-click the Start button on the taskbar.


3 Answers

finishAndRemoveTask() is the new API that as per the documentation "Finishes all activities in this task and removes it from the recent tasks list."

if(android.os.Build.VERSION.SDK_INT >= 21)
{
    finishAndRemoveTask();
}
else
{
    finish();
}
like image 171
Varun Bhatia Avatar answered Dec 15 '22 01:12

Varun Bhatia


Pressing (and holding) HOME button doesn't open task manager. This is some sort of "Recent Apps" section which shows you recently opened apps. Actually it is a bit smarter than that - it can restore last visited activity, but since you have only one activity, this shouldn't be really important for you

So basically even if you can see your app in this list, it doesn't mean it is actually running.

like image 44
Pavel Dudka Avatar answered Dec 15 '22 00:12

Pavel Dudka


finish() tells the android system that you are done. It is up to the android system to decide when to actually kill your application. It will keep your application around as long as the OS doesn't require the resources. For the OS, keeping your application in RAM is cheaper than restarting the app. This strategy is true for most modern OS.

like image 28
Srikant Sahay Avatar answered Dec 15 '22 00:12

Srikant Sahay