1

ユーザーの電話番号を入力して電話をかける編集テキストがあり、電話が鳴ったら、ユーザーが通話を切断するのではなく、自動的に通話を終了したいと考えています。プログラムでこれを達成するにはどうすればよいですか? これが私の MainActivityCode です:

    phnum = edNumber.getText().toString();
    Intent callIntent = new Intent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse("tel:" + phnum));


    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    startActivity(callIntent);
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }

マニフェスト:

<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
4

1 に答える 1

0

通話を終了するには、次の手順に従います。

  1. ユーザーが通話を終了した場合はパラメーターとして LOCAL を送信する setDisconnected(DisconnectCause)を呼び出し、相手が通話を終了した場合はパラメーターとして REMOTE を送信します。
  2. destroy() メソッドを呼び出します。もっとplsはここをクリックして知っています
于 2019-06-19T12:49:30.757 に答える