首页 » Andorid » 临时分类 » 正文

smscode-auto-reader

smscode-auto-reader

Android Arsenal

Help you to read sms code automatically.

How to User

1. Include SMS read permission

add`` 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;
}
下载 (1)

发表评论