How does Android get the verification code through the mobile phone to complete the registration function

When registering many apps or online accounts, you often need to obtain the verification code from the mobile phone to complete the registration. At that time, you were young. You just thought it was fun to obtain the verification code from the mobile phone. You didn't care too much about how she realized it and what the story behind her was like. Now in the project Xiaobian took over, you need to register through the mobile phone number, In addition, the mobile phone number sends the corresponding verification code to complete the registration, so how to click the button to obtain the verification code in some application apps to complete the whole process of registration? Today, Xiaobian will take registration as an example to share with our partners how to obtain the verification code through the mobile phone number to complete the whole process of registration, and how to use regular expressions to verify whether the mobile phone number meets the specifications of China Telecom, China Mobile and China Unicom.

The first step we need to do is to write the method to obtain the verification code in apiclient. The specific code is as follows:

The second step is to write the interface method in appcontent. The specific code is as follows:

Step 3: write a regular expression in stringutils to verify whether the number is a mobile phone number. The specific code is as follows:

Step 4: write the file in XML. The specific code is as follows:

Step 5: write the code in the Java class registeractivity, as shown below:

//--------------------------------Thread process for obtaining verification code -- complete------------------------------

//--------------------------------Registration thread processing -- start----------------------------------

//--------------------------------Registration thread processing --- complete-----------------------------------

Finally, let's run it to see our effect. Because we don't know why the genymotion can't run, we wronged our friends. We can't see the dynamic pictures, but it doesn't affect us. First, we can register with a number, as shown in the following figure:

Check the verification code received by the mobile phone:

Finally, let's look at our registration:

Message from Xiaobian: this blog post mainly briefly introduces how to obtain the verification code through the mobile phone to complete the function of registration, and how to use regular expression to verify whether the mobile phone number conforms to China Mobile, China Unicom and China Telecom. That sentence is not only a challenge but also an opportunity for Xiaobian, because knowledge is interlinked. In addition, Xiaobian will leave the most precious memory in his programming life. Although Xiaobian may not be engaged in the Android industry in the future, there are many kinds of things in the code world, some are sweet, some are warm, some are gently turned into songs, and some are continuous. In these stories, The only thing we have in common is that we used to love you very much in a year, a month, a quiet day! Love you -- during this internship, Android brought Xiaobian all kinds of surprises.

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