onActivityResult不叫进程被杀死之后, [英] onActivityResult is not called after process is killed
问题描述
我有一个主要活动(主)和其他活动(子)是从主调用
I have a main activity (Main) and another activity (Sub) that is called from Main by
startActivityForResult(new Intent(this, SubActivity.class), 25);
当我在子了,我杀死进程(使用任务管理器或通过亚行外壳杀< PID>
),我重新打开应用程序,我立即采取以子。
When I'm at Sub, and I kill the process (using a task manager or by adb shell kill <pid>
), and I re-open the application, I'm taken immediately to Sub.
在次我有这样的code回调到主要活动:
In Sub I have this code to call back to the Main activity:
setResult(RESULT_OK, data);
finish();
我会收到请求code(25),结果code(RESULT_OK)和数据上的 onActivityResult
如果我不杀的过程。然而,在这种情况下,我采取的主要活动,但 onActivityResult
不叫。
I would have received the requestCode (25), the resultCode (RESULT_OK) and the data on onActivityResult
if I didn't kill the process. However in this case I'm taken to the Main activity, but the onActivityResult
is not called.
这是怎么工作的Android(这是我不希望),或者是有什么毛病我的方法?
Is this how Android works (which I don't expect), or is there something wrong with my approach?
更新:这件事发生在我的Nexus One,的CyanogenMod 7.0.2,Android的2.3.3。我试着用模拟器API 10,安卓2.3.4,它的工作正如所料, onActivityResult
仍叫后我杀的过程。
Update: This happened on my Nexus One, CyanogenMod 7.0.2, Android 2.3.3. I tried using emulator API 10, Android 2.3.4 and it worked as expected, onActivityResult
is still called after I killed the process.
推荐答案
我面临同样的问题,我解决了更换startActivityForResult功能,并将结果存储到共享preferences后来在onResume加载它们。这里是链接到完整的解决方案。
I was facing the same problem and I solved it replacing the startActivityForResult functionality storing the result into the shared preferences and loading them later in onResume. Here's the link to the full solution.
这篇关于onActivityResult不叫进程被杀死之后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!