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

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

问题描述

如何在不调用其 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.

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

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