title: resultCode is always 0 and request is always -1, . Activity.onActivityResult();
body: <p>I would like to add this to another list of questions about <code>resultCode == 0</code> and <code>requestCode == 0</code>.</p>
  
  <p>Here is the synopsis:
  <code>NoteActivity</code> calls <code>NoteSettingsActivity</code> using <code>startActivityForResult()</code>.</p>
  
  <p>I have searched the web and when I pressed back button when <code>super.onBackPressed()</code>, the <code>resultCode == 0</code>. Well after further researching, it seems it returns this code whenever the back button is pressed, but after botching that <code>super.onBackPressed()</code> call and just simply <code>finish()</code> the application the <code>onActivityResult()</code>'s <code>resultCode</code> is still equals to 0. It goes the same with <code>requestCode</code>.</p>
  
  <p>Also, I tried manipulating the manifest file, I have done so many changes just to get this work but nothings works for me.</p>
  
  <p>Here is the snippet. Note that I have reverted back to my previous commit so I have lost my recent modifications, but please take a look on the code I have wrote before I notice that the <code>resultCode</code> is always equals to 0 (<code>ACTIVITY_CANCELED</code>) </p>
  
  <pre><code>@Override
  public void onNoteSettingsActivityCalled(Note note)
  {
      Intent intent = new Intent(this, NoteSettingsActivity.class);
      intent.putExtra(NoteExtrasKey.EXTRA_NOTE_ID, note.getNoteID());
  
      startActivityForResult(intent, NoteRequest.REQUEST_UPDATE_SETTINGS);
  }
  </code></pre>
  
  <p>Here is when the activity detected back press:</p>
  
  <pre><code>@Override
  public void onBackPressed()
  {   
      Log.i(NoteApplication.TAG, "NoteSettingsActivity.onBackPressed() has been called.");
  
      Intent intent = new Intent();
      intent.putExtra(NoteExtrasKey.EXTRA_NOTE_REMINDENABLED , mRemindEnabled);
      intent.putExtra(NoteExtrasKey.EXTRA_NOTE_REMINDEVERY   , mDaysSelected);
      intent.putExtra(NoteExtrasKey.EXTRA_NOTE_REMINDON      , String.valueOf(mRemindDateTime));
      intent.putExtra(NoteExtrasKey.EXTRA_NOTE_ID            , mTargetNoteID);
  
      if(getParent() != null)
          getParent().setResult(Activity.RESULT_OK, intent);
      else
          setResult(Activity.RESULT_OK, intent);
  
      super.onBackPressed();
  }
  </code></pre>
  
  <p>Here's how NoteActivity received the resulting call.</p>
  
  <pre><code>    @Override
  public void onActivityResult(int result, int request, Intent intent)
  {
      super.onActivityResult(result, request, intent);
  
      Log.i(NoteApplication.TAG, "NoteActivity.onActivityResult() has been called.");
      Log.i(NoteApplication.TAG, "NoteActivity.onActivityResult() result = " + result + " request = " + request);
  
      if(result == Activity.RESULT_CANCELED)
          return;
  
      switch(request)
      {
          case NoteRequest.REQUEST_UPDATE_SETTINGS:
  
              if(intent == null) return;
  
              int noteID = intent.getIntExtra(NoteExtrasKey.EXTRA_NOTE_ID, -1);
              String remindOnString = intent.getStringExtra(NoteExtrasKey.EXTRA_NOTE_REMINDON);
  
              if(remindOnString != null &amp;&amp; !remindOnString.equals(""))
                  mRemindDateTime = Timestamp.valueOf(remindOnString);
  
              mHasSettingsEnabled = true;
              mRemindEnabled = intent.getBooleanExtra(NoteExtrasKey.EXTRA_NOTE_REMINDENABLED, false);
              mSelectedDays = intent.getIntegerArrayListExtra(NoteExtrasKey.EXTRA_NOTE_REMINDEVERY);
  
              if(noteID &lt; 0)
              {
                  Note note = mNoteDatabaseHelper.getNote(noteID);
                  note.setRemindEnabled(mRemindEnabled);
                  note.remindEvery(mSelectedDays);
                  note.remindOn(mRemindDateTime);
  
                  onNoteItemUpdated(note); 
              }
  
              Log.i(NoteApplication.TAG, "NoteActivity.onActivityResult() NoteRequest.REQUEST_UPDATE_SETTINGS called.");
  
              break;
  
          default:
              Log.i(NoteApplication.TAG, "NoteActivity.onActivityResult() : unknown request code = " + request);
              break;
      }
  }
  </code></pre>
  
  <p><code>resultCode</code> equals 0 and <code>requestCode</code> requals -1 when I ran this. I have checked the intent passed on this and it is not null.</p>
  
  <p>Here are the questions very related to this question. None of them worked:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/4510280/android-onactivityresult-is-always-0">Android onActivityResult is always 0</a></li>
  <li><a href="https://stackoverflow.com/questions/3542107/how-do-i-handle-the-back-button-when-startactivityforresult-is-active">How do I handle the back button when startActivityForResult is
  active?</a></li>
  <li><a href="https://stackoverflow.com/questions/2679250/setresult-does-not-work-when-back-button-pressed">setResult does not work when BACK button pressed</a></li>
  <li><a href="https://stackoverflow.com/questions/1926284/android-startactivityforresult-always-gets-a-resultcode-of-0">Android: startActivityForResult always gets a resultCode of 0?</a></li>
  <li><a href="https://stackoverflow.com/questions/25615301/android-calendar-onactivityresults-resultcode-is-always-">Android Calendar: onActivityResult's resultCode is always 0</a></li>
  <li><a href="https://stackoverflow.com/questions/12191785/onactivityresult-always-returns-0">onActivityResult always returns 0</a></li>
  <li><a href="https://stackoverflow.com/questions/8460250/onactivityresult-is-being-called-at-an-unexpected-time">onActivityResult() is being called at an unexpected time</a></li>
  <li><a href="https://stackoverflow.com/questions/7910840/android-startactivityforresult-immediately-triggering-">Android - startActivityForResult immediately triggering
  onActivityResult</a></li>
  <li><a href="https://stackoverflow.com/questions/3354955/onactivityresult-called-prematurely">onActivityResult() called prematurely</a></li>
  <li><a href="https://stackoverflow.com/questions/15199404/activity-result-is-always-0">Activity result is always 0</a></li>
  <li><a href="https://stackoverflow.com/questions/5297361/android-gallery-intent-returning-resultcode-result-canceled">Android: Gallery intent returning resultCode == RESULT_CANCELED</a>
  <a href="https://stackoverflow.com/questions/18507043/android-on-activity-result-always-return-0-and-null-intent">Android on activity result always return 0 and null intent</a></li>
  </ul>
  
  <p>I am losing a lot of important hours working on my project just figuring out what makes the value for resultCode and requestCode lose the value I sent along the way.</p>
  
  <p>Any help and guidance will be appreciated. Thank you very much!</p>