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("http://127.0.0.1:4723/wd/hub"), 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 com.infiniti.atyourprice

Activity is com.infiniti.atyourprice.activity.Login

i want to switch from this activity to another Activity

com.infiniti.atyourprice.activity.SearchFlight

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
  }

  appium_driver.driver.start_activity(app_hash)

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(“com.infiniti.atyourprice”, “.activity.SearchFlight”);
try {
Thread.sleep(20000);
} catch (InterruptedException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}

waitUntilLocatedId(driver,waitFor,30);

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

findEle(driver,flightList+randomFlight+dateL,“xpath”).click();

waitUntilLocatedId(driver,proceedBtn,10);
findEle(driver,proceedBtn,“id”).click();

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?