title: onActivityResult not called on back button
body: <p>I'm having an issue with my "back button" on my android app.  I have an Activity called DashboardActivity that calls AskQuestionActivity.  I pass a value to AskQuestionActivity, and want to send that value back to DashboardActivity when the back button is pressed.  This is my code so far.  The child class is:  </p>
  
  <pre><code>public class AskQuestionActivity extends AppCompatActivity {
  
  private int userId;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.ask_question);
      setUserId(getIntent().getExtras().getInt("id"));
  }
  
  @Override
  public void onBackPressed() {
      Intent resultData = getIntent();
      resultData.putExtra("id", getUserId());
      setResult(2, resultData);
      finish();
  //    super.onBackPressed();
   }
  
  public int getUserId() {
      return userId;
  }
  
  public void setUserId(int userId) {
      this.userId = userId;
  }
  
  }
  </code></pre>
  
  <p>The parent class is: </p>
  
  <pre><code>public class DashboardActivity extends AppCompatActivity {
  
      private int userId;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.dashboard);
          setUserId(getIntent().getExtras().getInt("id"));
          DisplayMetrics dm = this.getResources().getDisplayMetrics();
  
          RelativeLayout linearLayout = (RelativeLayout) findViewById(R.id.dashboard);
  
          TextView availableQuestions = new TextView(this);
          RelativeLayout.LayoutParams relativeLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
          relativeLayout.setMargins(convertDpToPx(100,dm), convertDpToPx(40,dm), convertDpToPx(0,dm), convertDpToPx(0, dm));
          availableQuestions.setLayoutParams(relativeLayout);
          User u = getUser(this.userId);
  
          if (u.getAvailableQuestionCount() &gt; 0) {
              availableQuestions.setTextColor(Color.GREEN);
          } else {
              availableQuestions.setTextColor(Color.RED);
          }
          availableQuestions.setText("" + u.getAvailableQuestionCount());
          linearLayout.addView(availableQuestions);
      }
  
      public void askQuestion(View view) {
          Intent intent = new Intent(this, AskQuestionActivity.class);
          intent.putExtra("id", getUserId());
          startActivityForResult(intent, 2);
      }
  
      /**
       * gets the logged in user and populates the entity
       * @return
       */
      private User getUser(int id) {
          MySQLiteHelper mDbHelper = new MySQLiteHelper(getApplicationContext());
          SQLiteDatabase db = mDbHelper.getWritableDatabase();
          String[] selectionArgs = {String.valueOf(id)};
          Cursor cursor = db.query("user", null, "id=?", selectionArgs, null, null, null, null);
          User u = new User(new Long(id));
  
          if (cursor.moveToFirst()) {
              u.setUsername(cursor.getString(cursor.getColumnIndex("username")));
              u.setPassword(cursor.getString(cursor.getColumnIndex("password")));
              u.setAvailableQuestionCount(Integer.parseInt(cursor.getString(cursor.getColumnIndex("availableQuestionsCount"))));
              u.setAnswerCount(Integer.parseInt(cursor.getString(cursor.getColumnIndex("answerCount"))));
          } else {
              return null;
          }
          return u;
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          if (requestCode == RESULT_OK) {
              Intent intent = getIntent();
              setUserId(data.getIntExtra("id", 0));
          }
      }
          /**
           * getter for userId
           * @return
           */
      public int getUserId() {
          return userId;
      }
  
      /**
       * setter for userId
       * @param userId
       */
      public void setUserId(int userId) {
          this.userId = userId;
      }
  
      private int convertDpToPx(int dp, DisplayMetrics displayMetrics) {
          float pixels = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, displayMetrics);
          return Math.round(pixels);
      }
  
      }
  </code></pre>
  
  <p>and my manifest file is: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.amk27.pollit" &gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name"
              android:theme="@style/AppTheme.NoActionBar" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".CreateAccountActivity"
              android:label="CreateAccountActivity"
              android:parentActivityName=".MainActivity" &gt;
              &lt;meta-data
                  android:name="android.support.PARENT_ACTIVITY"
                  android:value=".MainActivity" /&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".DashboardActivity"
              android:label="DashboardActivity"
              android:parentActivityName=".MainActivity" &gt;
              &lt;meta-data
                  android:name="android.support.PARENT_ACTIVITY"
                  android:value=".MainActivity" /&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".AskQuestionActivity"
              android:label="AskQuestionActivity"
              android:parentActivityName=".DashboardActivity" &gt;
              &lt;meta-data
                  android:name="android.support.PARENT_ACTIVITY"
                  android:value=".DashboardActivity" /&gt;
          &lt;/activity&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>The problem seems to be that in the parent class, onActivityResult is never called.  onCreate seems to be called instead.  I'm not sure what is causing this, so if anyone could shed some light on the situation, I would greatly appreciate it.  </p>
  
  <p>Thanks!</p>