Search code examples
javaselenium-webdriverappiumappium-android

How to use mobile: startActivity with OptionalIntentArguments?


After updating my Appium dependency to version 9.1.0, I am no longer able to use ((AndroidDriver) driver).startActivty(activity) : https://github.com/appium/java-client/pull/2036

With Appium version 8.5.1, I was able to start my Android Activity like so

  Activity activity = new Activity("com.android.settings", ".applications.InstalledAppDetails")
      .setOptionalIntentArguments("package:com.android.chrome");
  ((AndroidDriver) DriverManager.getDriver()).startActivity(activity);

How can I launch the package:com.android.chrome activity using mobile: startActivity?

The package:com.android.chrome should open on the Android device


Solution

  • Using the java-client v9.1.0 dependency you can pass the package:com.android.chrome as a URI argument.

    driver.executeScript("mobile: startActivity",
    ImmutableMap.of( "action", "android.settings.APPLICATION_DETAILS_SETTINGS", 
    "uri","package:com.android.chrome"));
    

    mobile: startActivity arguments: https://github.com/appium/appium-uiautomator2-driver?tab=readme-ov-file#mobile-startactivity