<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.jatin.notification">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:launchMode="singleInstance" > <!-- Activity A -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".NotificationActivity"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".DialogActivity"
android:excludeFromRecents="true"
android:noHistory="true"
android:theme="@style/Theme.AppCompat.Dialog.MinWidth" />
<activity
android:name=".SecondActivity" /><!-- Activity B -->
</application>
</manifest>
According to Single Instance,the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task; any activities started by this one open in a separate task.
But, when i navigated from Activity A(Launcher Activity)-> Activity B via startActivity(intent*) instead of being in new Task Activity B gets on top of Activity A's task. Though when i navigated to A from B via startActivity(intent*) it shows single instance of A.
*NO FLAGS WERE ADDED.
Why did Activity B pushed on top of Activity A(as Activity had the launch mode : "singleInstance") instead of creating a new task?
List of activities :
TaskRecord{14ba4a25 #18 A=com.example.nischay.notification U=0 sz=2} Run #1: ActivityRecord{2a37b313 u0 com.example.nischay.notification/.SecondActivity t18} Run #0: ActivityRecord{1ab16fa7 u0 com.example.nischay.notification/.MainActivity t18}
mResumedActivity: ActivityRecord{2a37b313 u0 com.example.nischay.notification/.SecondActivity t18}
mLastPausedActivity: ActivityRecord{1ab16fa7 u0 com.example.nischay.notification/.MainActivity t18}
Details :
Device : Lenovo k50a40 Android Version : 5.0 CompileSdkVersion : 25
Code
Intent intent = new Intent(MainActivity.this, SecondActivity.class); startActivityForResult(intent, REQUEST_CODE_NOTIFY);