Hi,
I wanted to reproduce situation shown here:
http://developer.android.com/guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes
Where I start app using activity X0, then start activity A1 as new
task and open activity A2 as single task. Next I open activity B1 as
new task, then I start activity B2 and then I'd like to switch to
activity A2. On back I would go to A1, then B2, B1 and finally to X0.
Here is my manifest:
<application
android:icon="@drawable/icon"
android:label="@string/app_name">
<activity
android:name="X0"
android:label="@string/app_name">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="A1"
android:allowTaskReparenting="false"
android:taskAffinity="@string/task_A"
android:label="@string/app_name">
</activity>
<activity
android:name="A2"
android:allowTaskReparenting="false"
android:taskAffinity="@string/task_A"
android:launchMode="singleTop"
android:label="@string/app_name">
</activity>
<activity
android:name="B1"
android:allowTaskReparenting="false"
android:taskAffinity="@string/task_B"
android:label="@string/app_name">
</activity>
<activity
android:name="B2"
android:allowTaskReparenting="false"
android:taskAffinity="@string/task_B"
android:launchMode="singleTask"
android:label="@string/app_name">
</activity>
</application>
At first I hadn't any allowTaskReparenting nor taskAffinity, I started
to experiment with those settings.
And here is my code for activity, it's the same among activities:
((TextView) findViewById(R.id.title)).setText("X0" + getTaskId() +
isTaskRoot()); //some debugging
findViewById(R.id.a1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),
A1.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
startActivity(intent);
}
});
findViewById(R.id.a2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),
A2.class);
startActivity(intent);
}
});
findViewById(R.id.b1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),
B1.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
startActivity(intent);
}
});
findViewById(R.id.b2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),
B2.class);
startActivity(intent);
}
});
Now I'm clicking A1, A2, B1, B2, A2 and the A2 should be from task A,
but it opens new activity A2 in stack B.
Is it possible to switch between tasks that I've created?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en