startActivityForResult serResult

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.

猜你喜欢

转载自charlotte.iteye.com/blog/1495351