title: Why do I not get the result back from my startActivityForResult?
body: <p>I have one class <code>LogBeerActivity</code> that extends <code>AppCompatActivity</code> and has these two methods:</p>
  
  <pre><code>public void gotoAddBrewery(View view) {
      String breweryNameEntered = breweryTextView.getText().toString();
      Intent intent = new Intent(this, AddBreweryActivity.class);
      intent.putExtra(Constants.EXTRAS_ID_BREWERY_NAME, breweryNameEntered);
      startActivityForResult(intent, ADD_BREWERY_REQUEST_CODE);
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      Log.d(TAG_LOG_BEER_ACTIVITY, "Got request result code: " + resultCode);
      super.onActivityResult(requestCode, resultCode, data);
      switch (requestCode)
      {
          case ADD_BREWERY_REQUEST_CODE:
              if (resultCode == RESULT_OK)
              {
                  String breweryName = data.getStringExtra(AddBreweryActivity.BREWERY_NAME_CODE);
                  breweryTextView.setText(breweryName);
              }
      }
  }
  </code></pre>
  
  <p>The other class <code>AddBreweryActivity</code> also extends <code>AppCompatActivity</code> and it has this method called when its form with user input is submitted:</p>
  
  <pre><code>public void submitBrewery(View view) {
      EditText breweryLocationInput = findViewById(R.id.input_brewery_location);
      EditText breweryCountryInput = findViewById(R.id.input_brewery_country);
      if (breweryNameInput == null || breweryLocationInput == null || breweryCountryInput == null) {
          Log.e(TAG_ADD_BREWERY_ACTIVITY, "One of the inputs is null!");
          return;
      } else {
          String enteredBreweryName = breweryNameInput.getText().toString().trim();
          String enteredBreweryLocation = breweryLocationInput.getText().toString().trim();
          String enteredBreweryCountry = breweryCountryInput.getText().toString().trim();
          Log.d(TAG_ADD_BREWERY_ACTIVITY, "submitBeer clicked. Brewery: " + enteredBreweryName + " from: " + enteredBreweryLocation + " in: " + enteredBreweryCountry);
          if (!enteredBreweryName.isEmpty() &amp;&amp; !enteredBreweryLocation.isEmpty() &amp;&amp; !enteredBreweryCountry.isEmpty()) {
              NewBrewery newBrewery = new NewBrewery(enteredBreweryName, enteredBreweryLocation, enteredBreweryCountry);
              URL url = HttpHelper.getUrl(Constants.URL_BASE + Constants.URL_BREWERIES_PATH);
              Thread thread = new Thread(() -&gt; {
                  try {
                      HttpHelper.makeRequest(url, newBrewery, this);
                  } catch (IOException e) {
                      Log.e(TAG_ADD_BREWERY_ACTIVITY, "Error trying to submit new brewery: ", e);
                      return;
                  } catch (HttpHelper.UserNotLoggedInException e) {
                      Log.e(TAG_ADD_BREWERY_ACTIVITY, "Error trying to submit new brewery: ", e);
                      return;
                  }
              });
              thread.start();
              Intent resultIndent = new Intent();
              resultIndent.putExtra(BREWERY_NAME_CODE, newBrewery.getName());
              setResult(Activity.RESULT_OK, resultIndent);
              finish();
          }
      }
  }
  </code></pre>
  
  <p>However, the <code>onActivityResult</code> method never gets called, even though the flow between the two activities happens as expected.</p>
  
  <p><strong>EDIT:</strong> I've made a discovery. If I comment out the lines of code that do the HTTP request to my server (From the line starting with <code>URL url = ...</code> until and including the line starting with <code>thread.start();</code> then it works. Is it something to do with starting the new thread that messes things up? In fact, it's enough to just comment out the line that reads <code>thread.start();</code> and it works (except the http request isn't made, of course).</p>