Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

OTP Reading for Android - Automatically reades SMS for verification purpose in Android , read otp from sms android

NotificationsYou must be signed in to change notification settings

swarajsaaj/otpReader

Repository files navigation

OTP (One-Time Password) Reader Library for Android helping easily implement listening of SMS messages and using the callback methods to perform password verification etc.

Gradle Dependencies

build.gradle (module)

implementation 'swarajsaaj:otpreader:1.1'

Usage

To implement the Otp reader in the application:-

  1. Implement the following service in AndroidManifest.xml
 <receiver android:name="swarajsaaj.smscodereader.receivers.OtpReader">        <intent-filter>            <action android:name="android.provider.Telephony.SMS_RECEIVED"/>        </intent-filter></receiver>
  1. Add SMS reading permissions in AndroidManifes.xml
    <uses-permission android:name="android.permission.RECEIVE_SMS" />    <uses-permission android:name="android.permission.READ_SMS" />
  1. Implement the OTPListener Interface in your activity
public class MainActivity extends ActionBarActivity implements OTPListener {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        OtpReader.bind(this,"SENDER_NUM_HERE");    }        @Override    public void otpReceived(String smsText) {        //Do whatever you want to do with the text        Toast.makeText(this,"Got "+smsText,Toast.LENGTH_LONG).show();        Log.d("Otp",smsText);    }}
  1. Bind the current Activity (or OTPListener) to OtpReader with second argument as the sender number (e.g. if it might be like BM-BIZY, DM-BIZY you can give this argument as "BIZY" or some constant like 9898982222 , enter any extract substring of the expected number here or leave it blank to read all incoming messages. If not left blank the numbers containing the string will be considered for listening).
OtpReader.bind(this,"SENDER_NUM_HERE");

Override the otpReceived method

  @Override    public void otpReceived(String smsText) {        //Do whatever you want to do with the text        Toast.makeText(this,"Got "+smsText,Toast.LENGTH_LONG).show();        Log.d("Otp",smsText);    }

Thats it. otpReceived will be called when the message is received.

About

OTP Reading for Android - Automatically reades SMS for verification purpose in Android , read otp from sms android

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp