开发者

TabGroupActivity startChildActivity - pause currentActivity

开发者 https://www.devze.com 2023-04-08 21:14 出处:网络
Extending TabGroupActivity, when I start a new childActivity: public void startChildActivity(String Id, Intent intent) {

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

精彩评论

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