1

Even though this question is duplicate of this, It can not resolve my problem. My problem is when I launch app through hyperlink in mail, my app is opening again as a new task even though app is already in background. I'm using android:launchMode="standard"

If I use android:launchMode="singleTask", It solves my problem but every time when I launch app from home screen Its start from splash screen activity even though app is in background. Please suggest solution to resolve above two issues.

I also read about launch mode in google doc. But my mind do not have that much knowledge to observe. Thank you in advance.

Community
  • 1
  • 1
Aristo Michael
  • 2,166
  • 3
  • 35
  • 43

1 Answers1

1

This is working for me with launchMode="singleTask"

Add this to onCreate and you should be good to go:

if (!isTaskRoot()) {
        final Intent intent = getIntent();
        final String intentAction = intent.getAction();
        if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) {
            Log.w("LOG_TAG", "Main Activity is not the root.  Finishing Main Activity instead of launching.");
            finish();
            return;
        }
}

Answer taken from here.

Thanks buddy.

Community
  • 1
  • 1
Aristo Michael
  • 2,166
  • 3
  • 35
  • 43