How to change new activity in the same package

private static WebDriver androidOS(String appPkg,String appAct)throws MalformedURLException {
    capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "emulator-5554");

    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("appPackage", appPkg);

    capabilities.setCapability("appActivity", appAct);
    driver = new AndroidDriver(new URL(""), capabilities);
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    return driver;

My current Activity is .activity.SearchFlight

how to change this activity

@selva, what is the problem you are trying to solve? Do you need to start your app with a different intent?

My package is

Activity is

i want to switch from this activity to another Activity

Appium (now) allows you to start an application and activity other than the one under test. We’ve implemented our code in Ruby, but the same functionality should be present in Java:

  app_hash = {
      app_package: my_package,
      app_activity: my_activity


thank you for your reply,
My problem is

when we are stating new activity the app is getting closed,

Is there any possiblity to continue…?

((AndroidDriver) driver).startActivity(“”, “.activity.SearchFlight”);
try {
} catch (InterruptedException e2) {
// TODO Auto-generated catch block


int randomFlight=getRandonmNuber(0,5);
try {
} catch (InterruptedException e1) {
// TODO Auto-generated catch block



Is your application getting closed and restarted, or just closed? If the former, what are you expecting to happen that’s not happening?

If you were performing this operation as a normal user, how would you do it? Is it possible to follow the same steps?