This is how to HangUp PhoneCall in Android 9.0 BUT how to do it in Android 10.0

GolfMan 21 Reputation points
2020-12-28T19:40:00.997+00:00
    void IncomingCallHang()
    {
        var manager = (TelephonyManager)Application.Context.GetSystemService(Context.TelephonyService);

        IntPtr TelephonyManager_getITelephony = JNIEnv.GetMethodID(
                manager.Class.Handle,
                "getITelephony",
                "()Lcom/android/internal/telephony/ITelephony;");

        IntPtr telephony = JNIEnv.CallObjectMethod(manager.Handle, TelephonyManager_getITelephony);
        IntPtr ITelephony_class = JNIEnv.GetObjectClass(telephony);
        IntPtr ITelephony_endCall = JNIEnv.GetMethodID(
                ITelephony_class,
                "endCall",
                "()Z");
        JNIEnv.CallBooleanMethod(telephony, ITelephony_endCall);
        JNIEnv.DeleteLocalRef(telephony);
        JNIEnv.DeleteLocalRef(ITelephony_class);

        //Toast.MakeText(context, telephoneNumber + "Is Blocked", ToastLength.Long).Show();
    }
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,160 questions
{count} votes