title: OnActivityResult activity error : Failure delivering result ResultInfo
body: <blockquote>
    <p>error : Failure delivering result ResultInfo{who=null, request=100,
    result=-1, data=Intent {
    dat=content://com.android.providers.media.documents/document/image:28362
    flg=0x1 }} to activity
    {com.projectbox.uploadfile/com.projectbox.uploadfile.MainActivity}:
    java.lang.NullPo</p>
  </blockquote>
  
  <pre><code>  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (requestCode == PICK_IMAGE &amp;&amp; resultCode == Activity.RESULT_OK) {
          android.net.Uri selectedImage = data.getData();
          String[] filePathColumn = {MediaStore.Images.Media.DATA};
          android.database.Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
          if (cursor == null)
              return;
  
          cursor.moveToFirst();
  
          int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
          String filePath = cursor.getString(columnIndex);
          cursor.close();
  
          File file = new File(filePath);
  
          RequestBody reqFile = RequestBody.create(MediaType.parse("image/*"), file);
          MultipartBody.Part body = MultipartBody.Part.createFormData("banner", file.getName(), reqFile);
          RequestBody name = RequestBody.create(MediaType.parse("text/plain"), "banner");
  
          Log.d("THIS", data.getData().getPath());
  
          retrofit2.Call&lt;okhttp3.ResponseBody&gt; req = service.postImage(body, name);
          req.enqueue(new Callback&lt;ResponseBody&gt;() {
              @Override
              public void onResponse(Call&lt;ResponseBody&gt; call, Response&lt;ResponseBody&gt; response) {
  
              }
  
              @Override
              public void onFailure(Call&lt;ResponseBody&gt; call, Throwable t) {
                  Log.e("FFF", t.getMessage());
                  t.printStackTrace();
              }
          });
      }
  }
  </code></pre>
  
  <p>Error stack:</p>
  
  <pre><code>Process: com.projectbox.uploadfile, PID: 17822
  java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:28362 flg=0x1 }} to activity {com.projectbox.uploadfile/com.projectbox.uploadfile.MainActivity}: java.lang.NullPointerException
  at android.app.ActivityThread.deliverResults(ActivityThread.java:4220)
  at android.app.ActivityThread.handleSendResult(ActivityThread.java:4263)
  at android.app.ActivityThread.-wrap20(ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1601)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:154)
  at android.app.ActivityThread.main(ActivityThread.java:6349)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
  Caused by: java.lang.NullPointerException
  at java.io.File.&lt;init&gt;(File.java:262)
  at com.projectbox.uploadfile.MainActivity.onActivityResult(MainActivity.java:110)
  at android.app.Activity.dispatchActivityResult(Activity.java:7025)
  at android.app.ActivityThread.deliverResults(ActivityThread.java:4216)
  at android.app.ActivityThread.handleSendResult(ActivityThread.java:4263) 
  at android.app.ActivityThread.-wrap20(ActivityThread.java)                                                                
  </code></pre>