Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to forward the calls to voice mail in android programmatically

I do not know how to forward the calls to voice mail programmatically in android ?

like image 821
AndroidRaji Avatar asked Sep 25 '12 12:09

AndroidRaji


1 Answers

The selected answer is only correct if you want to limit your implementation to the Android public SDK.

It is possible to send a call to voice mail programmatically on Android.

While the phone is ringing, end the call. The call will be diverted to voice mail by the network. In GSM/WCDMA this is a feature called User Determined User Busy or UDUB, it also works on CDMA devices.

There are plenty of answers on SO on how to end a call on Android:

Using Java reflection and the iTelephony interface:

End call in android programmatically or end incoming call programmatically

== Update 2020 ==

Since Android P it is possible to hangup calls using the Android SDK - therefore forwarding to voicemail is now a supported feature of Android.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
    TelecomManager tcm = context.getSystemService(TelecomManager.class);
    if(tcm != null)
        tcm.endCall();
}

Add the necessary permission to AndroidManifest.xml

    <uses-permission android:name="android.permission. ANSWER_PHONE_CALLS" />
like image 85
BitByteDog Avatar answered Nov 20 '22 01:11

BitByteDog