Activity A、B,A用startActivityForResult跳转B,B为singleTask,发现B setResult(int,intent)的int设置和A的onActivityResult 得到不一样,A的onActivityResult每次得到均为0.以下为原因:
Launch an activity for which you would like a result when it finished. When this activity exits, your onActivityResult() method will be called with the given requestCode. Using a negative requestCode is the same as calling startActivity(Intent) (the activity is not launched as a sub-activity).
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.
本文探讨了在使用startActivityForResult启动一个singleTask模式的Activity时遇到的问题:即设置的结果码无法正确传递回原Activity。文章解释了singleTask模式的特点,并说明了为什么这种模式下会导致返回结果丢失。

被折叠的 条评论
为什么被折叠?



