The problem is that I need to call the onActivityResult method for MainActivity. In this activity, I turn first to the "Search" activity, and then to the "Add member" activity. After in the activity "Add member", click on the button "Add member". It should call onActivityResult on the MainActivity.

Code from AddMember to call MainActivity:

Intent intentDealCreation = new Intent(AddMemberInfoActivity.this, MainActivity.class); startActivityForResult(intentDealCreation,1); 

Code in MainActivity:

 @Override protected void onActivityResult(int requestCode, int resultCode, Intent result) { super.onActivityResult(requestCode, resultCode, result); if (resultCode == RESULT_OK) { Toast.makeText(this,"Привет, я тут!!!", Toast.LENGTH_SHORT).show(); } } 
  • Activation you start with requestCode = 1, and in Result you do not check for it and want to catch this activation? - PeDuCKA

1 answer 1

You then need to call from the search activity to call startActivityForResult for AddMemberInfoActivity, on the call to AddMember, you must transfer the data back to the search activity and close AddMemberInfoActivity. This is done like this:

 Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); 

In the search activity, you will be taken to onActivityResult there, again you must transfer the data back to MainActivity and close the search activity. And only then you will be taken to onActivityResult for MainActivity. And now you have the code to launch the new MainActivity. You in onActivityResult will not get in any way this way.