Posts

Showing posts with the label automatic

Read sms automatically to verify OTP

Reading incoming message automatically in android to verify OTP Here I am going to explain how to read the incoming message in android automatically to verify OTP without  closing the app. Step 1. Read Sms . class import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsManager; import android.telephony.SmsMessage; import android.util.Log; public class ReadSms extends BroadcastReceiver { @Override public void onReceive ( Context context, Intent intent) { final Bundle bundle = intent.getExtras(); try { if (bundle != null) { final Object[] pdusObj = ( Object[] ) bundle.get("pdus"); for ( int i = 0; i < pdusObj.length; i++) { SmsMessage currentMessage = SmsMessage.createFromPdu((byt...