如何使用 Appium 从一个本机应用程序切换到另一个本机应用程序?

How to switch from one native to another native app using Appium?

我必须从运行时本机应用程序切换到另一个本机应用程序。尝试使用下面提到的 startActivty() 方法:

driver.startActivity(settingsAppPackageName, settingsAppActivityName); 

&

driver.startActivity(new Activity("package.activityname"));

使用带有 v1.4.1 的 appium 桌面 任何来自自动化极客的解决方案都将不胜感激。

终于找到了解决办法

static void launchSecurityXxxApp(AppiumDriver<AndroidElement> driver) throws MalformedURLException {

    String appPackage="com.xxx.xxxx";
    String appActivity="com.xxx.xxxx.Launchable";
    Activity activity = new Activity(appPackage, appActivity);
    activity.setStopApp(false);
    ((AndroidDriver<AndroidElement>) driver).startActivity(activity);
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
protected static final String appPackage1="app package name";
protected static final String appActivity1="your activity name";
protected static final String appPackage2="app package name";
protected static final String appActivity2="your activity name";

public static AndroidDriver<MobileElement> setupDriver(String appPackage, String appActivity) throws MalformedURLException {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("deviceName", "Any na,e");
        caps.setCapability("udid", "your device uuid");
        caps.setCapability("platformName", "Android");
        caps.setCapability("platformVersion", "your device android version");
        caps.setCapability("appPackage", appPackage);
        caps.setCapability("appActivity", appActivity);    
        caps.setCapability("noReset", "true");

        return new AndroidDriver<MobileElement>(new URL(
                "http://127.0.0.1:4723/wd/hub"), caps);
    }

public static void main(String[] args) throws MalformedURLException {
    AppiumDriver<MobileElement> driver=setupDriver(appPackage1, appActivity1);

    driver=setupDriver(appPackage2, appActivity2);
}