android startActivityForResult is killing a thread within the parent activity

百般思念 提交于 2019-12-24 01:33:06

问题


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.

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..


回答1:


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.

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.



来源:https://stackoverflow.com/questions/3754360/android-startactivityforresult-is-killing-a-thread-within-the-parent-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!