singleTask, startActivityForResult不能共存的问题

原因未知,设置了目标BActivity为singleTask后,在AActivity中调用BActivity,例如

Intent intent = new Intent(this, BActivity.class);

startActivityForResult(intent, 1);

结果先会调用到  AActivity中的onActivityResult,而在BActivity设置setResult(Activity.RESULT_OL)后,AActivity的onActivityResult不会接受到通知。

 

解决方案:设置BActivity为singleTop.

 

 

Note that this method should only be used with Intent protocols that are defined to return a result. In other protocols (such as ACTION_MAIN or ACTION_VIEW), you may not get the result when you expect. For example, if the activity you are launching uses the singleTask launch mode, it will not run in your task and thus you will immediately receive a cancel result.

http://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)

posted on 2011-08-23 12:20  还有什么  阅读(2555)  评论(0编辑  收藏  举报

导航