title: What is difference between OnActivityResult() and OnNewResult()?
body: <p><a href="https://i.stack.imgur.com/Z5H64.png" rel="nofollow noreferrer">Please look at this photo</a></p>
  
  <p>I want to make an application looks like that photo..</p>
  
  <p>When I click the button to MainActivity on sub-activities,
  OnActivityResult() and OnNewIntent() are all called in MainActicity.</p>
  
  <p>I intend to call OnActivityResult() for coming back from MenuActivity,
  and to call OnNewIntent() for coming back from subs.</p>
  
  <p>I learned mother activity calls child activity through StartActivityForResult(),
  and child calls setResult() for return.
  And when the objective activity that I want to call is alive,
  I learned onNewContent() is needed because objective activity doesn't call onCrete().</p>
  
  <p>But I think I'm wrong. Plz let me know what is the difference of OnActivityResult() and OnNewResult()?
  and also I want to know why OnActivityResult is called even though setResult is not called in setResult().</p>
  
  <p>Thank you in advance.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  EditText editText;
  EditText editText2;
  
  public static final int REQUEST_CODE_MENU = 100;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      editText = (EditText) findViewById(R.id.editText);
      editText2 = (EditText) findViewById(R.id.editText2);
  
      Button button = (Button) findViewById(R.id.button);
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              if(editText.getText().toString().length() != 0 &amp;&amp;
                      editText2.getText().toString().length() != 0){
                  Intent intent = new Intent(getApplicationContext(), MenuActivity.class);
                  startActivityForResult(intent, REQUEST_CODE_MENU);
              } else {
                  Toast.makeText(getApplicationContext(),"ID와 비밀번호를 입력해주세요.", Toast.LENGTH_LONG).show();
              }
          }
      });
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
  
  
      if (requestCode == REQUEST_CODE_MENU) {
          if (resultCode == RESULT_OK) {
              Toast.makeText(getApplicationContext(), "MenuActivity에서 온 Intent입니다.", Toast.LENGTH_LONG).show();
          } else {
              Toast.makeText(getApplicationContext(), "ERROR :  The value of resultCode is not RESULT_OK", Toast.LENGTH_LONG).show();
          }
      } else if {
          Toast.makeText(getApplicationContext(), "ERROR :  The value of requestCode is not REQUEST_CODE_MENU (100)", Toast.LENGTH_LONG).show();
      }
  }
  
  @Override
  protected void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      Toast.makeText(getApplicationContext(), intent.getStringExtra("from") + "에서 온 Intent입니다.", Toast.LENGTH_LONG).show();
    }
  }
  </code></pre>
  
  <p>MenuActivity.java</p>
  
  <pre><code>public class MenuActivity extends AppCompatActivity {
  
  public static final int REQUEST_CODE_CUSTOM = 200;
  public static final int REQUEST_CODE_REVENUE = 300;
  public static final int REQUEST_CODE_PRODUCT = 400;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_menu);
  
      Button custom = (Button) findViewById(R.id.custom);
      custom.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent_cus = new Intent(getApplicationContext(), CustomActivity.class);
              startActivityForResult(intent_cus, REQUEST_CODE_CUSTOM);
          }
      });
  
      Button revenue = (Button) findViewById(R.id.revenue);
      revenue.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent_rev = new Intent(getApplicationContext(), RevenueActivity.class);
              startActivityForResult(intent_rev, REQUEST_CODE_REVENUE);
          }
      });
  
      Button product = (Button) findViewById(R.id.product);
      product.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent_pro = new Intent(getApplicationContext(), ProductActivity.class);
              startActivityForResult(intent_pro, REQUEST_CODE_PRODUCT);
          }
      });
  
      Button tologin = (Button) findViewById(R.id.tologin);
      tologin.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent intent_login = new Intent(getApplicationContext(), MainActivity.class);
              setResult(RESULT_OK, intent_login);
              finish();
          }
      });
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      switch(requestCode){
          case REQUEST_CODE_CUSTOM :
              Toast.makeText(getApplicationContext(), data.getStringExtra("from") + "에서 온 Intent입니다.", Toast.LENGTH_LONG).show(); break;
          case REQUEST_CODE_PRODUCT :
              Toast.makeText(getApplicationContext(), data.getStringExtra("from") + "에서 온 Intent입니다.", Toast.LENGTH_LONG).show(); break;
          case REQUEST_CODE_REVENUE :
              Toast.makeText(getApplicationContext(), data.getStringExtra("from") + "에서 온 Intent입니다.", Toast.LENGTH_LONG).show(); break;
          default :
              Toast.makeText(getApplicationContext(), "ERROR occured.", Toast.LENGTH_LONG).show();
      }
    }
  }
  </code></pre>
  
  <p>CustomActivity.java
  (one of sub activities, it's code is perfectly same with other sub-activities)</p>
  
  <pre><code>public class CustomActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_custom);
  
      Button tomenu = (Button) findViewById(R.id.tomenu);
      Button tologin = (Button) findViewById(R.id.tologin);
  
      tomenu.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent from_cus = new Intent(getApplicationContext(), MenuActivity.class);
              from_cus.putExtra("from", "CustomActivity");
              setResult(RESULT_OK, from_cus);
              finish();
          }
      });
  
      tologin.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent from_cus = new Intent(getApplicationContext(), MainActivity.class);
              from_cus.putExtra("from", "CustomActivity");
              from_cus.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_CLEAR_TOP);
              startActivity(from_cus);
              finish();
          }
      });
    }
  }
  </code></pre>