Search code examples
javaandroidandroid-intentonactivityresult

When getting the error: ResultInfo{who=null, request=0, result=-1, data=null}, What is the who=null?


protected void onActivityResult(int reqCode, int resCode, Intent data){
    super.onActivityResult(reqCode, resCode, data);

In the paramters you got requestCode, resultCode and data. But in the error you also get the "who". What is this, and where is it coming from


Solution

  • It's the ID of the activity. Often it's null. When your activity code is running, the activity has already been identified an it does not need to be reflected in the method signature.

    If you're interested where the id comes from, here's some starting points for backtracing:

    1. ResultInfo that produces the string representation
    2. sendActivityResult() that constructs ResultInfo with an id
    3. startActivityForResult() that calls sendActivityResult with mEmbeddedID
    4. mEmbeddedID initialized in attach()
    5. attach() called by ActivityThread