Вернуться к приложению после звонка
я пытаюсь сделать телефонный звонок из приложения
и я хочу вернуть его обратно в приложение после звонка
я задал этот вопрос на этом форуме, но я нене понимаю ответ
Как сделать телефонный звонок в Android и вернуться к моей активности, когда звонок сделан?
public void call() {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:048598077"));
getContext().startActivity(callIntent);
} catch (ActivityNotFoundException activityException) {
Log.e("dialing-example", "Call failed", activityException);}
finally {
EndCallListener callListener = new EndCallListener();
TelephonyManager mTM = (TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE);
mTM.listen(callListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
private class EndCallListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if(TelephonyManager.CALL_STATE_RINGING == state) {
Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
}
if(TelephonyManager.CALL_STATE_OFFHOOK == state) {
//wait for phone to go offhook (probably set a boolean flag) so you know your app initiated the call.
Log.i(LOG_TAG, "OFFHOOK");
}
if(TelephonyManager.CALL_STATE_IDLE == state) {
//when this state occurs, and your flag is set, restart your app
Log.i(LOG_TAG, "IDLE");
}
}
я понимаю кое-что подобное, но я неначатьCallListener
в любой точке. Так как я могу это сделать?