How to open app from Recently open apps in android device using Appium?

Hi All,

How to open app from Recently open apps in android device using Appium ?

Scenario :

I am testing app where I have to interact with OTP from SMS during testing so I am looking for solution like how can I switch back to my app after read OTP.

Steps :

  1. Open My app
  2. Enter Mobile Number
  3. Open SMS , Read OTP
  4. Again Open my app from recently open apps and enter OTP

Any help would be appreciated.

Regards,
Rahul Bhatt

You can start your app activity:

((AndroidDriver) driver).startActivity(new Activity(ANDROID_PACKAGE, ANDROID_STARTACTIVITY));

Thanks
But startActivity doesn’t work for android driver.
should i import new dependency for startActivity and new Activity ?

startActivity only works for AndroidDriver. Can you share your code and make sure the import for AndroidDriver and Activity is:

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.Activity;