Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resume last activity when launcher icon is clicked

Tags:

android

As I see most of application resumes last activity when launcher icon is clicked. However it seems that this is not default behavior. In my application launcher activity is always started when launcher icon is clicked.

How can i configure my application to resume last activity when launcher icon is clicked and application is already running.

like image 414
Alexey Zakharov Avatar asked Oct 30 '11 10:10

Alexey Zakharov


1 Answers

Problem:

I'm not qualified to say this a bug, but this behaviour has been around since the first Android version. There is a problem with tasks and roottasks in release builds when starting the application from the launcher. You can find the related bug report here.

Solution:

It can be fixed adding following code to your onCreate of your launcher activity:

if (!isTaskRoot()) {
    finish();
    return;
}
like image 66
Tobrun Avatar answered Dec 03 '22 06:12

Tobrun