I have this function:

public void onClick(View v) { String phoneNumber = ((EditText)findViewById(R.id.phoneNumber)).getText().toString(); Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phoneNumber)); startActivity(intent); } 

I need that after the call is completed (the call window is closed and returned to my application), some of my functions are callEnded() , for example callEnded() . How to do this? PS Maybe it's better to make calls somehow differently? Because you need to make a lot of calls and automatically ...

  • How to track through the onResume lifecycle event? - MiMEKiZ
  • @MiMEKiZ onResume is called twice - before the call and after. And it is not called when calling. - Metalofon Play

1 answer 1

The standard way is to use instead of startActivity() - startActivityForResult() , after the end of the Intent, the onActivityResult() method will be called where you can do something, in particular, check how the Intent was completed and so on.

Manual about such

Documentation here

  • I tried to use something like that, but there’s a problem that onActivityResult I’ve called twice, before the call and after ... - Metalofon Play