Android SMS verification code auto fill function

The author found that in many applications, there is the function of automatically obtaining the verification code: click the button to obtain the verification code and receive the SMS. The current application can obtain the verification code in the SMS without exiting the program and fill it automatically. I think this user experience is great. There is no need for users to switch back and forth between SMS and app. How is this function realized? In fact, it's very simple. It uses a thing called contentobserver in Android. Here's a simple manual implementation~~~

1、 Contentobserver is mainly developed to monitor the contents of the inbox. Once a new message comes, it will monitor whether it is the message sent by the number I want. If so, it will be intercepted directly with regular expression

2、 Layout and activity

3、 Don't forget to add permissions < uses permission Android: name = "Android. Permission. Read_sms" / >

4、 I run the test with two mobile phones~~~

Automatically obtain SMS verification code.png

Code address: https://github.com/yungfan/SMSSMSContentObserver

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>