私は次のコードを持っており、発信通話の呼び出し状態は、2 者間の電話が接続されているときにアクティブであり、相手が実際にあなたが電話していることを確認して電話に出ることができることを読みました。アイドル状態は通話が切断されたときで、OFF_HOOK 状態はボタンを押してダイヤルした瞬間です。OFF_HOOK と IDLE 状態になっていますが、呼び出し状態にはなりません。何が問題でしょうか? .任意の助けをいただければ幸いです。
public void onReceive(final Context context, Intent intent) {
TelephonyManager Tm=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Tm.listen(new PhoneStateListener(){
public void onCallStateChanged(int state,String number) {
super.onCallStateChanged(state, number);
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
//when Idle i.e no call
Toast.makeText(context, "Phone state Idle", 1).show();
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
//when Off hook i.e in call
//Make intent and start your service here
Toast.makeText(context, "Phone state Off hook", 1).show();
break;
case TelephonyManager.CALL_STATE_RINGING:
Toast.makeText(context, "Phone state Ringing", 1).show();
break;
default:
break;
}
}
},PhoneStateListener.LISTEN_CALL_STATE);