0

Extending TabGroupActivity, when I start a new childActivity:

public void startChildActivity(String Id, Intent intent) {
    Window window = getLocalActivityManager().startActivity(Id,
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    if (window != null) {
        activityIdList.add(Id);
        setContentView(window.getDecorView());
    }
}

How can I put the current activity into the pause state?

Because after I start a child activity in this way, when I restart it, then the on create method is run. How can I avoid this?

Found one solution is to use another flag:

Intent.FLAG_ACTIVITY_REORDER_TO_FRONT

but not sure if it is the best solution

P.P.S Another solution is to add an boolean intent to the startChildActivity method:

public void startChildActivity(String Id, Intent intent) {
    intent.addExtra("resume", true);
    Window window = getLocalActivityManager().startActivity(Id,
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    if (window != null) {
        activityIdList.add(Id);
        setContentView(window.getDecorView());
    }
}

and then retrieve it from the child activity and check if the activity is restarted or not

1 Answers1

0

Try putting this in activity tag in the manifest file

android:launchMode="singleTask"

It should look something like this

<activity android:name=".dashboard.DashboardActivity" android:screenOrientation="portrait"
        android:launchMode="singleTask"/>
blessanm86
  • 31,439
  • 14
  • 68
  • 79
  • Great! But what is the difference between single task and single instance? –  Sep 27 '11 at 12:30
  • 1
    This is a good read http://stackoverflow.com/questions/3219726/android-singletask-or-singleinstance-launch-mode. – blessanm86 Sep 27 '11 at 14:09