smscode-auto-reader

Additional

Language
Java
Version
N/A
Created
May 11, 2015
Updated
Jul 19, 2016 (Retired)
Owner
Sim Sun (simpleton)
Contributor
Sim Sun (simpleton)
1
Activity
Badge
Generate
Download
Source code

Announcement

smscode-auto-reader

Help you to read sms code automatically.

How to User

###1. Include SMS read permission

add<uses-permission android:name="android.permission.READ_SMS" /> in your AndroidManifest.xml file

###2. Import library from gradle

compile 'com.simsun.scra:library:0.0.2'

###3. Register the observer in your code

Put the below codes to your onCreate callback

smsObserver = new SmsContentObserver(
    new Handler(),
    YOURACTIVITY.this,
    new String[]{"[your_tag_name]", [your_other_tag_name]},
    smsCode -> {
        if (StringUtil.isPresent(smsCode)) {
            smscodeEt.setText(smsCode);
        }
    }
);

###4. Unregister the observer in your code

Put the below codes to your onDestory callback

if (smsObserver != null) {
    smsObserver.unregisterSMSObserver();
    smsObserver = null;
}