As per android developer documentation
Android 8.0 (API level 26) introduces several new permissions related to telephony: The ANSWER_PHONE_CALLS p
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(); }