未完成就将活动发送到后台 [英] Sending Activity to background without finishing

查看:64
本文介绍了未完成就将活动发送到后台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不调用其finish()方法的情况下使活动进入后台并返回开始该活动的父级活动?我做了很多尝试,但是找不到解决方案.因此,如果你们能帮助我,我将非常感激.

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 not find a solution. So if you guys could help I would be very thankful.

推荐答案

如果Activity在与其父级不同的任务中运行,则以下内容将起作用.为此,请参见 http://developer.android.com/guide/topics/manifest/activity-element.html#lmode .

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.

这篇关于未完成就将活动发送到后台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆