android.permission.ANSWER_PHONE_CALLS How I can use? for auto answer

后端 未结 3 1471
没有蜡笔的小新
没有蜡笔的小新 2021-01-07 04:59

As per android developer documentation

Android 8.0 (API level 26) introduces several new permissions related to telephony: The ANSWER_PHONE_CALLS p

3条回答
  •  滥情空心
    2021-01-07 05:56

    https://developer.android.com/reference/android/telecom/TelecomManager.html#acceptRingingCall()

    Acccept Answer call is deprecated API LEVEL Q

    try {
                        Toast.makeText(CallAnswerDialog.this, "btn_answer click", Toast.LENGTH_SHORT).show();
    
                        TelecomManager tm = (TelecomManager) CallAnswerDialog.this.getSystemService(Context.TELECOM_SERVICE);
                        if (tm == null) {
                            // whether you want to handle this is up to you really
                            throw new NullPointerException("tm == null");
                        }
                        tm.acceptRingingCall();   // is deprecated Now API Level Q
                        btn_answer.setVisibility(View.GONE);
                    }catch (Exception e){
                        e.printStackTrace(); }
    

提交回复
热议问题