How to make a phone call in android and come back to my activity when the call is done?

后端 未结 20 2180
北恋
北恋 2020-11-22 12:59

I am launching an activity to make a phone call, but when I pressed the \'end call\' button, it does not go back to my activity. Can you please tell me how can I launch a c

20条回答
  •  囚心锁ツ
    2020-11-22 13:23

    Inside PhoneStateListener after seeing the call is finished better use:

    Intent intent = new Intent(CallDispatcherActivity.this, CallDispatcherActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    

    Where CallDispatcherActivity is the activity where the user has launched a call (to a taxi service dispatcher, in my case). This just removes Android telephony app from the top, the user gets back instead of ugly code I saw here.

提交回复
热议问题