Reputation: 1
I'm developing an Android application that automatically picks up incoming calls on a device (let's call it Device B). I am done with the auto-pick call. Now I want to disable the default calling screen because i want make it no destructive to user.
if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) {
Toast.makeText(context, "Incoming call detected", Toast.LENGTH_SHORT).show();
TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
if (telecomManager != null) {
if (ContextCompat.checkSelfPermission(context, android.Manifest.permission.ANSWER_PHONE_CALLS) == PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
telecomManager.acceptRingingCall();
}
} else {
Toast.makeText(context, "Permission not granted", Toast.LENGTH_SHORT).show();
}
}
}
Upvotes: 0
Views: 35