Sending Activity to background without finishing

前端 未结 5 974
臣服心动
臣服心动 2020-12-05 14:53

How can I make an activity go to background without calling its finish() method and return to the Parent activity that started this? I tried so much but I could

5条回答
  •  暖寄归人
    2020-12-05 15:32

    The following will work if the Activity is running in a different task to its parent. To achieve this, see http://developer.android.com/guide/topics/manifest/activity-element.html#lmode.

    public void onBackPressed () {
        moveTaskToBack (true);
    }
    

    The current task will be hidden, but its state will remain untouched, and when it is reactivated it will appear just as it was when you left it.

提交回复
热议问题