Automate OTP (Android) while using Appium

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: