开发者

TabGroupActivity startChildActivity - pause currentActivity

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(Inten开发者_如何转开发t.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


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"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜