机器人startActivityForResult是父活动内杀死一个线程 [英] android startActivityForResult is killing a thread within the parent activity

查看:110
本文介绍了机器人startActivityForResult是父活动内杀死一个线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个线程,并在其中一个视图中的活动......他们可疑类似LunarLander。为了展示一个在游戏菜单,我打电话的startActivityForResult为具有一些关于它的按钮不同的活动......这是然后返回pssed到父活动的按钮式$ P $。这是罚款,除非我继续在父活动,原来的线程我现在已经终止。我想这是因为发生了父活动已经失去焦点,因此该线程被认为是死了,但我想继续与线程。

I have an activity which has a thread and a view in it...they're suspiciously similar to LunarLander. To show an in-game menu, i'm calling the startActivityForResult for a different activity which has a number of buttons on it...this is then returning the button type pressed to the parent activity. This is fine except when I carry on in the parent activity, the original thread I had is now TERMINATED. I guess this is happening because the parent activity has lost focus and so the thread is considered dead, but I want to carry on with the thread.

有没有什么办法可以让线程活着吗?我试过的意图为新的活动setFlags,但我还没有发现任何维护它。

Is there any way I can keep the thread alive? I've tried setFlags on the intent for the new activity but i've not found anything that maintains it..

推荐答案

我放弃了,决定作弊。而不是试图返回从子活动的家长,我又重新父活动。

I gave up and decided to cheat. Instead of trying to return to the parent from the child activity, i'm recreating the parent activity again.

所以我gameActivity创建menuActivity,然后使用inGameMenuIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)报废;旗。然后menuActivity做的东西,当按钮被pressed它创建一个新gameActivity和menuActivity报废。

So my gameActivity creates the menuActivity and then is scrapped using the inGameMenuIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); flag. Then the menuActivity does its stuff and when a button is pressed it creates a new gameActivity and menuActivity is scrapped.

这篇关于机器人startActivityForResult是父活动内杀死一个线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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