Android 9 Development Cookbook(Third Edition)
上QQ阅读APP看书,第一时间看更新

There's more...

Besides the result code, onActivityResults() also includes a Request Code. Are you wondering where that came from? It is simply the integer value that was passed with the startActivityForResult() call, which takes this form:

startActivityForResult(Intent intent, int requestCode); 

We didn't check the request code because we knew we had only one result to handle, but in non-trivial applications with several activities, this value can be used to identify which Activity is returning a result.

If startActivityForResult() is called with a negative request code, it will behave the same as if we used  startActivity(), that is, it will not return a result.