Forum Xamarin.Android

accept the incoming phone call clicking on a button

corradocorrado Member ✭✭

I have to make that by clicking on a button, it accept the incoming phone call.
This is the my code but it does not work

Intent buttonDown = new Intent(Intent.ActionMediaButton);
buttonDown.PutExtra(Intent.ExtraKeyEvent, new KeyEvent(KeyEventActions.Up, Keycode.Headsethook));
context.SendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");


  • robbitrobbit CNMember Xamurai

    Hi @corrado,

    Have you used the AudioManager to register?

  • corradocorrado Member ✭✭

    No, the code I posted works on android 4.4.2 but not on newer versions of android

  • KrzysztofKacpuraKrzysztofKacpura USMember
    edited June 2018

    Did you add necessary permissions to the Manifest?

  • corradocorrado Member ✭✭
    edited June 2018

    These are all permissions to the Manifest

    uses-permission android:name="android.permission.INTERNET"
    uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
    uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
    uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
    uses-permission android:name="android.permission.READ_PHONE_STATE"
    uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
    uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    uses-permission android:name="android.permission.ANSWER_PHONE_CALLS"
    uses-permission android:name="android.permission.CALL_PRIVILEGED"
    uses-permission android:name="android.permission.MODIFY_PHONE_STATE"
    uses-permission android:name="android.permission.CALL_PHONE"

  • And do you request them from user when system is 5.0 or higher?

  • corradocorrado Member ✭✭

    Yes, I request runtime permissions (phone, storage, location); I used the plugin Plugin.Permissions

Sign In or Register to comment.