# Automate OTP (Android) while using Appium

**URL:** <https://discuss.appium.io/t/automate-otp-android-while-using-appium/19490>\
**Category:** Issues/Bugs\
**Created:** [November 6, 2017, 1:05pm UTC](https://discuss.appium.io/t/automate-otp-android-while-using-appium/19490 "2017-11-06T13:05:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gireesh05](https://discuss.appium.io/user_avatar/discuss.appium.io/gireesh05/32/6367_2.png) [@Gireesh05](https://discuss.appium.io/u/Gireesh05)\
**Post date:** [November 6, 2017, 1:05pm UTC](https://discuss.appium.io/t/automate-otp-android-while-using-appium/19490/1 "2017-11-06T13:05:29Z")

</div>

Hi,

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.

Regards,  
Gireesh.

---

<div class="post-metadata">

**Author:** ![Telmo\_Cardoso](https://discuss.appium.io/user_avatar/discuss.appium.io/telmo_cardoso/32/1435_2.png) [@Telmo\_Cardoso](https://discuss.appium.io/u/Telmo_Cardoso)\
**Post date:** [November 6, 2017, 1:09pm UTC](https://discuss.appium.io/t/automate-otp-android-while-using-appium/19490/2 "2017-11-06T13:09:28Z")

</div>

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:

> [@\[How to\] Read SMS from native messaging app (p.e. to read OTP)](http://discuss.appium.io/t/how-to-read-sms-from-native-messaging-app-p-e-to-read-otp/10409):
>
> Hi, There as been couple request to read SMS received, mainly SMS containing some kind of verification code (OTP). This is my attempt to do so in a more standard way (without having to write code for each native messaging app). For Android I picked one random SMS Popup App from play store and extracted the apk. You can access it in here: [SMSPopup.apk](https://drive.google.com/file/d/0B-74TiHf9jopVXJXeVJ3NW9zSFE) I implemented a class where you can install the SMS reader app, enabled it, read SMS and uninstall it. The class is available in here: [Extr…](https://gist.github.com/tfcardoso/9ab8845121f2cee2a79e342a60b99fcf)
