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.
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.
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();
}
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With