startActivityForResult 收不到 resultCode 的诡异问题

RT


今天怎么弄,在onActivityResult里面收到的resultCode都是0,不是我自己设置的值



搞了半天,终于发现原因了,singletask的activity不行。



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 收不到 resultCode 的诡异问题)