Is there any way to do the following process in android Automation using Appium with android driver?
Press home button from some specific screen. Put app in backgrou
Both iOS and Android support the following methods :
(AppiumDriver)driver.runAppInBackground(10);//put app in background for 10 seconds
(AppiumDriver)driver.launchApp();//launch the app again
Hope it helps!
Try to focus on the current activity you were in :
(AppiumDriver)driver.runAppInBackground(10);
(AppiumDriver)driver.currentActivity();
or
Try to start the same activity you were in :
(AppiumDriver)driver.runAppInBackground(10);
(AppiumDriver)driver.startActivity("appPackage","com.example.android.apis", null, null);
public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("appPackage", "appActivity");
} catch (Exception e) {
e.printStackTrace();
}
}
You have to enter your app package name and activity name to maximize the app. For Eg:
public static void minimizeMaximize() {
try {
driver.runAppInBackground(10);
((AndroidDriver) driver).startActivity("com.example.test", "com.example.LaunchApp");
} catch (Exception e) {
e.printStackTrace();
}
}
This will definitely work.
This will navigate to the Gmail App while executing your Appium script. You Just Change the package name & activity of your app.
Activity activity = new Activity("com.google.android.gm", "com.google.android.gm.ConversationListActivityGmail");
activity.setStopApp(false);
((AndroidDriver<MobileElement>) driver).startActivity(activity);