How to "actually" kill the app (without clearing the current data)

Hi guys, so I just tried Appium command driver.closeApp() on android but what I just realise is that the app is not actually killed by the Appium, it was just like sitting in the background. What I need is I like to kill the app without resetting the actual data (like on ios driver.terminateApp(‘bundleId’). For example the manual step is like this:

Given User is on home page of an App
When User open tab window
And User swipe up on the current App
Then the App is killed

please let me know if you guys have any interesting ideas regarding my issue. Thank you.

note: I am using javascript :slight_smile:

Same terminate command by package name.

hi, thanks for the reply. for clarification do you mean like this?

driver.terminateApp("com.google.com")

yes → https://appium.io/docs/en/commands/device/app/terminate-app/

// Java
// updated Oct 2024

// get appID
String appID = null;
if (driver instanceof AndroidDriver)
  appID = (String) driver.getCapabilities().getCapability(UiAutomator2Options.APP_PACKAGE_OPTION);
else if (driver instanceof IOSDriver)
  appID = String.valueOf(driver.getCapabilities().getCapability(XCUITestOptions.BUNDLE_ID_OPTION));
// terminate app
((InteractsWithApps) driver).terminateApp(appID);
// launch app
((InteractsWithApps) driver).activateApp(appID);