Automate OTP (Android) while using Appium


I am trying to automate OTP received. I want to know how to switch from one app to another and any method/command to get the OTP from messages.

When i tried to use driver.startActivity(AppPackageName, AppActivityName); getting an error like

“The method startActivity(Activity) in the type StartsActivity is not applicable for the arguments (String, String)”.

Please help me to resolve the issue.


What you trying to do is:

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

In Android, OTP will be received by different apps depending on the device you are automating, so maybe you could try: