title: Android: Failure delivering result ResultInfo. Intent is apparently null?
body: <p>I'm trying to have the user pick an <strong>audio file</strong> and store the path of that audio file. I'm doing so by using an <strong>ACTION_GET_CONTENT Intent</strong> so the user can pick an application to choose the file with. For some reason though, in the <strong>onActivityResult</strong> method, the <strong>Intent data</strong> is being returned as <strong>null</strong>, as is shown in the error message. Logcat error message and relevant code is given below. Any help would be greatly appreciated.</p>
  
  <p><strong>MAJOR EDIT:- This error only occurs when I press the back button or CANCEL ! Choosing a music file actually works fine. Sorry about that. Nonetheless, the error persists.</strong></p>
  
  <p>LogCat Error:-</p>
  
  <pre><code>06-26 16:36:25.238: E/AndroidRuntime(24759): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {com.packagename.appname.activityname}: java.lang.NullPointerException
  </code></pre>
  
  <p>Call to chooser activity placed in a method which is invoked in onCreate():-</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
  intent.setAction(Intent.ACTION_PICK);
  intent.setType("audio/*");
  startActivityForResult(intent, audioreminder);
  </code></pre>
  
  <p>onActivityResult() method:-</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      SharedPreferences flags = this.getSharedPreferences(
              "screen_on_flags", MODE_WORLD_READABLE);
      SharedPreferences.Editor editor = flags.edit();
      String FilePath = data.getData().getPath();
      switch (requestCode) {
      case audioreminder: {
          if (resultCode == RESULT_OK) {
              editor.putString("audioreminderpath", FilePath);
              editor.commit();
          } else if (resultCode == RESULT_CANCELED){
              CheckBoxPreference other_audioreminder = (CheckBoxPreference) findPreference("other_audioreminder");
              other_audioreminder.setChecked(false);
              }
          break;
      }
      }
  }
  </code></pre>