I have a sample app with 3 activities: Main, A and B. None of them has any launchMode.
Now I do this:
- open the app, Main activity is displayed
- leave the app using back button, so that there is no activity running
- receive a broadcast which starts a new activity A (new_task flag)
- open activity B by clicking on a button in activity A (no flags)
- receive a broadcast which starts a new activity A (new_task flag)
- new activity A is not started (if I go back, there's still the previous Activity A)
At step #6, activity A should be presented but is not.
If I try to present activity C instead (in #5), it is presented as expected.
If in #2 I leave the app by homebutton instead, everything works as expected.
How is this possible? And how can I ensure that the activity is always presented? I could use FLAG_ACTIVITY_CLEAR_TOP|FLAG_ACTIVITY_SINGLE_TOP
, but I want to maintain the backstack.
UPDATE - SOURCE: You can look at the source, but I am using Xamarin (which is basically native Android written in C#, very similar to Java). This is the content of the built manifest (removed the Xamarin stuff):
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="28" android:compileSdkVersionCodename="9" package="com.companyname.StartTest" platformBuildVersionCode="28" platformBuildVersionName="9">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:allowBackup="true" android:debuggable="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:name="android.app.Application" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
<activity android:label="A" android:name="A"/>
<activity android:label="B" android:name="B"/>
<activity android:label="@string/app_name" android:name="MainActivity" android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<receiver android:name="Receiver"/>
</application>
</manifest>