1

Overview

I have an Android app with two activities:

  • Activity A is an onboarding with intent-filter as MAIN, LAUNCHER and launchmode singleTask
  • Activity B is a WebView that took data from Activity A

On first load a user will onboard and then startActivity() takes them to Activity B with a finish(). ActivityB is technically the main activity view I want the user to be seeing from now on for the rest of the future. I do set preferences so that Activity A will segue to B on the next close/open.

Behavior

When the app is backgrounded and then resumed, Activity B refreshes the webpage each time. It appears the app goes through Activity A and then B which has a loadUrl(). Why does singleTask run through the entire app?

Not setting launchMode or using singleInstance results in Activity A being properly ignored and staying on Activity B. However I was using singleTask because of an unrelated Branch.io setup.

Some info on this: https://inthecheesefactory.com/blog/understand-android-activity-launchmode/en

Related: Android:Understanding how does an activity start when application launches

ericjam
  • 1,501
  • 2
  • 20
  • 30

0 Answers0