How to pick an incoming call using appium in android

I am trying to answer an android incoming call using Appium but no luck. Swipe gestures does not work here.

DesiredCapabilities cap_1 = new DesiredCapabilities();

           cap_1.setCapability("appium:deviceName","Galaxy A15 5G");
           cap_1.setCapability("platformName","Android");
           cap_1.setCapability("appium:platformVersion","14");
           cap_1.setCapability("browserName","Android");
           cap_1.setCapability("appium:udid","MYUDID");
           cap_1.setCapability("appium:automationName", 
"UiAutomator2");

URL url = new URL("http://127.0.0.1:4723/wd/hub");

WebElement element = driver_mb1.findElement(By.xpath("//android.view.ViewGroup[@resource-id="com.samsung.android.incallui:id/accept_button_in_3_way"]"));

driver_mb1 = new AppiumDriver(url,cap_1);
JavascriptExecutor js = (JavascriptExecutor) driver_mb1;
       Map<String, Object> params = new HashMap<>();
       params.put("elementId",element);
       params.put("direction","left");
       params.put("percent",0.75);
       js.executeScript("mobile:swipeGesture",params);

try better adb command way

adb shell input keyevent KEYCODE_CALL

you also can execute it with driver command GitHub - appium/appium-uiautomator2-driver: Appium driver for Android UIAutomator2

1 Like

Hi Aleksei, Extermely sorry for the late response. I have found that adb commands can handle and started using it but it really takes more than 30 seconds to pick a call which is a blocker for me.
There was a command earlier in Appium - acceptcall() which was quite faster but looks like it is depricated. Any insights why adb commands takes too long?

It should be really fast as it pure adb command.
If you try it manually in console without appium?

1 Like

I will try and let you know.