在Fragment中调用startActivityForResult()后requestCode发生改变

 

You are calling startActivityForResult() from your Fragment. When you do this, the requestCode is changed by the Activity that owns the Fragment.

If you want to get the correct resultCode in your activity try this:

Change:

startActivityForResult(intent, 1);

To:

getActivity().startActivityForResult(intent, 1);


简而言之,就是先获取到该Fragment所挂载的Activity,然后再调用startActivityForResult(intent, 1);

你可能感兴趣的:(Adroid)