This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 8
Nov 2018

I an trying to switch between the chrome browser and a hybrid app .Is there is any way to switch between the apps without relaunching it. I have gone through some blogs and support pages but saw that the apps will be relaunched when calling driver.startActivity().So i need some workaround where the apps will bot get relaunched. Please let me know if there is any other method that can be used.

  • created

    Nov '18
  • last reply

    Dec '18
  • 7

    replies

  • 287

    views

  • 4

    users

  • 1

    link

If it’s for Android try using adb commands:

Call this method twice and you will be able to switch between apps
public static void switchApp(){
runCommand(“adb shell input keyevent KEYCODE_APP_SWITCH”);
}

here is the runCommand:
public static String runCommand(String command){
String output = null;
try{
Scanner scanner = new Scanner(Runtime.getRuntime().exec(command).getInputStream()).useDelimiter("\A");
if(scanner.hasNext()) output = scanner.next();
}catch (IOException e){
throw new RuntimeException(e.getMessage());
}
return output;
}

8 days later