Reputation: 9212
I am using this flag in manifest.xml
to have only one instance of the activity.
android:launchMode="singleInstance"
But if this activity say A launches a new activity say B and then pressing back button on B not showing activity A. It is showing activity from where we launched A.
Basically i want to create a activity if it is not in stack and if in stack bring on the top. But back button should also work properly.
What flag i should use for this.
Upvotes: 0
Views: 831
Reputation: 5375
use android:launchMode="singleTask" instead of android:launchMode="singleInstance"
Upvotes: 1
Reputation: 1671
following code activityA(parent activity),then A launch activity b. Declare these lines in manifest.xml file. When click back button it goes to previous activity(i.e A(parent)).
<activity
android:name=".ActivityB"
android:label="@string/app_name"
android:parentActivityName=".ActivityA"
android:windowSoftInputMode="adjustPan" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prathap.ActivityA" />
</activity>
Upvotes: 0