My App has different activities. The first Activity shown is the SplashActivity
, which will instantly either open the AuthActivity
or if authorized the MainActivty
.
From the MainActivity
it is possible to navigate to further activities, i'll now just reference as OtherActivity
.
My Problem is:
Whenever i start the app from the Play Store Installation dialog that says "open app", then log in, navigate to OtherActivity
, put the app in background and click on the launcher icon of my app, the MainActivity
is shown.
However, after killing the app and opening it via the launcher icon, navigating to OtherActivity
, putting the app in background, opening it again via the launcher, the OtherActivity
is shown.
The Question: How can this be fixed, so that the OtherActivity
always stays on top?
So far i could find out, that the difference between launching from playstore and launching from launcher is the category: android.intent.category.LAUNCHER
simulate Play Store: adb shell am start -a android.intent.action.MAIN -n com.example/com.example.SplashActivity
simulate Launcher: adb shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n com.example/com.example.SplashActivity
The manifest looks like this:
<activity
android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="*"
android:scheme="com.example" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="*"
android:scheme="com.example" />
</intent-filter>
</activity>
Edit: I think this is related to this issue
Edit: The OtherActivity
is registered in the manifest and started as follows:
<activity
android:name=".OtherActivity"
android:label=""
android:theme="@style/AppTheme"/>
startActivity(
Intent().apply {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
setClassName(context, "com.example.OtherActivity")
}
)
question from:
https://stackoverflow.com/questions/65886750/top-activity-is-removed-whenever-started-from-play-store-and-put-back-to-backgro