Android uses contentobserver mode to obtain SMS, and uses regular auto fill verification code

Recently, when registering, I saw many apps directly fill in the verification code to the interface when the mobile phone receives a short message, omitting the user's automatic input. I felt that this was really humanized, ha ha, so I made one myself

Steps:

First of all, I used contentobserver to listen for text messages (it's better to know which number your verification code is sent from)

Then use regular grouping to get the verification code from the SMS (of course, what format the verification code must be)

Post key codes:

Register to listen to SMS database

After listening, remember getcontentresolver(). Unregistercontentobserver (c); Log off listening

In this way, you can monitor the changes of SMS database. Remember to add permissions and list SMS permissions by the way

The above is what Xiaobian introduced to you. Android uses contentobserver mode to obtain SMS and uses regular automatic filling verification code. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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
分享
二维码
< <上一篇
下一篇>>