Mobandroid Free Verification SMS

Source: Internet
Author: User

First, get user Appkey and app Secret

1. Create a new project in Eclipse (same as Android Studio) Note the package name, which is required when the mob background creates the app. This must be remembered!

650) this.width=650; "Src=" http://ugc.qpic.cn/adapt/0/79fe78c3-7fb2-c3e5-a1b6-a4bebb48596e/800?pt=0&ek=1 &kp=1&sce=0-12-12 "alt=" Get user Appkey and app Secret "/>

2. Login mob.com SMS Verification Platform Developer Service platform to register as a developer and create apps.

1) Select the version of the system, Android or iOS;

2) Fill in the Application name, select the application's detailed classification;

3) After the completion of the development model, the official launch of the time also need to upload the application of the signature, here is used to the above package name, it is best not to modify later, otherwise it is troublesome, need to make big changes in space.

650) this.width=650; "alt=" Create App "border=" 0 "height=" 211 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ A0c4b4fd-3e58-7bcf-3d95-f0f01c4df14d/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" to create the app "vspace=" 0 "width=" "Style=" Margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle;font-weight:inherit ; font-style:inherit;font-family:inherit;width:450px;height:211px; "/>

3, get the user Appkey and app Secret, when you create a new application, he will give you the corresponding application of Appkey and app Secret. If later need to enter mob.com view Appkey and app secret need to click the corresponding app name---application management----application information, here you can see

And can also modify some of the information in the app.

650) this.width=650; "alt=" Get user Appkey and app Secret "border=" 0 "height=" 280 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ 3b3183a8-28a6-3fa3-6769-f568faadae20/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" Get user Appkey and App Secret " Vspace= "0" width= "style=" margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle; font-weight:inherit;font-style:inherit;font-family:inherit;width:450px;height:280px; "/>

4, download the SDK, address: http://sms.mob.com/Download

Download the compressed package, unzip to get two files, one is the official sample, and the other is the project file that needs to be referenced in its own project.

Second, the client configuration

1. Import eclipse from the official Download SDK, import the SMSSDK project into eclipse as a whole and reference it as the library in the project you created. Where SMSSDK is an official reference resource file, this is a common way, because this eliminates the large number of add jar packages in their own projects, resulting in the volume of its own project is expanding, so that its loading speed is slow, but also because some of the jar package is only used in a very small part of it, However, the whole jar package is added, resulting in volume redundancy and waste of resources.

Import:

650) this.width=650; "alt=" Import file "border=" 0 "height=" 248 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ 1f3af027-8f7b-8f82-808d-e6a8967f7928/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" import file "vspace=" 0 "width=" "Style=" Margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle;font-weight:inherit ; font-style:inherit;font-family:inherit;width:300px;height:248px; "/>

Reference:

Follow these steps to refer the resource files you need to your project in step-by-step

Window--------Preferences---------android----Right library-------Add------Select Smssdk----------Apply---------OK

650) this.width=650; "alt=" Resource Introduction Project "border=" 0 "height=" 328 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ 0574adf0-6de8-32e4-76dd-f4ef84088380/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" Resource Introduction Project "vspace=" 0 "width= "Style=" Margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle;font-weight: inherit;font-style:inherit;font-family:inherit;width:450px;height:328px; "/>

2, open the configuration file, add the appropriate permissions

There are more common network permissions, address Book permissions, SMS permissions, etc.

These direct copies, sticky into their own projects can be, are necessary, there is nothing to say

<uses-permission android:name= "Android.permission.READ_CONTACTS"/>

<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>

<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/>

<uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>

<uses-permission android:name= "Android.permission.INTERNET"/>

<uses-permission android:name= "Android.permission.RECEIVE_SMS"/>

<uses-permission android:name= "Android.permission.GET_TASKS"/>

<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION"/>


3, add mob.com activity in application, this is provided in the official class library, but because it needs to be called in the personal project, it needs to be declared separately in the configuration file.

This should be a special reminder, do not forget, or you will be prompted null pointer exception or did not find Cn.smssdk.SMSSDKUIShell, so that your project can not run, if there is such an error prompt, you can directly to the configuration file to see if there is no missing this step.

<activity

Android:name= "Cn.smssdk.SMSSDKUIShell"

Android:configchanges= "Keyboardhidden|orientation|screensize"

Android:theme= "@android: Style/theme.translucent.notitlebar"

Android:windowsoftinputmode= "Statehidden|adjustresize"/>

The following also need to be declared in the configuration file, but this is their official use for statistical data used to get

<!--statistics, service is guaranteed to be able to upload data to the server-

<service

Android:name= "Cn.sharesdk.analysis.server.RemoteService"

android:process= ": Remote"/>

Third, method invocation

Initializing the SMS SDK

private void init () {

Myutils.initinfor (this);

SMSSDK.INITSDK (This, App_key, App_secret);

Final Handler Handler = new Handler (this);

EventHandler EventHandler = new EventHandler () {

public void Afterevent (int event, int result, Object data) {

Message msg = new Message ();

Msg.arg1 = event;

MSG.ARG2 = result;

Msg.obj = data;

Handler.sendmessage (msg);

}

};

Register Callback Listener Interface

Smssdk.registereventhandler (EventHandler);

Flag = true;

Get the number of new friends

ShowDialog ();

Smssdk.getnewfriendscount ();

}

Request SMS Verification Code

Btn.setonclicklistener (New View.onclicklistener () {

@Override

public void OnClick (View v) {

TODO auto-generated Method Stub

Str_phone = Phone.gettext (). toString ();

if (Str_phone.equals (""))

{

Toast.maketext (Getapplicationcontext (), "Please enter phone number", Toast.length_short). Show ();

}

else if (! Myutils.ismobileno (Str_phone))

{

Toast.maketext (Getapplicationcontext (), "Please enter the correct phone number format", Toast.length_short). Show ();

}

Else

{

The following code is the way to call the SDK to send text messages, where the "86" is defined in the official, representing China's meaning

The second parameter is the number of the phone that needs to send the SMS.

Smssdk.getverificationcode ("Str_phone");

Str_str_phone = Str_phone;

The Verification Code button will be activated after sending the SMS.

Btn_.setbackgroundcolor (0xff000000);

Btn_.setclickable (TRUE);

This button is not highlighted in 10 seconds

Time.start ();

}

}

});

Verify that the SMS verification code is correct

Smssdk.submitverificationcode ("Str_str_phone,str_captcha");

EventHandler eh=new EventHandler ()

{

@Override

public void Afterevent (int event, int result, Object data) {

if (result = = Smssdk. Result_complete)

{

Runonuithread (New Runnable ()

{

public void Run ()

{

Toast.maketext (Getapplicationcontext (), "Verify success!" You can change the password ", Toast.length_short). Show ();

Btn_.setbackgroundcolor (0XFFCCCCCC);

Btn_.setclickable (FALSE);

}

});

}

Else

{

Runonuithread (New Runnable ()

{

public void Run ()

{

Toast.maketext (Getapplicationcontext (), "CAPTCHA Error! ", Toast.length_short). Show ();

Btn_.setbackgroundcolor (0XFFCCCCCC);

Btn_.setclickable (FALSE);

}

});

((throwable) data). Printstacktrace ();

}

}

};

Smssdk.registereventhandler (EH); Register SMS Back

A regular expression that determines whether a string is a cell phone number

public static Boolean Ismobileno (String mobiles) {

/*

* Mobile: 134, 135, 136, 137, 138, 139, 150, 151, 157 (TD), 158, 159, 187, 188

* China Unicom: 130, 131, 132, 152, 155, 156, 185, 186 Telecom: 133, 153, 180, 189, (1349 Wei Tong)

* summed up is the first bit must be 1, the second must be 3 or 5 or 8, other locations can be 0-9

*/

String Telregex = "[1][3578]\\d{9}";//"[1]" represents the 1th digit 1, "[358]" for the second bit can be 3, 5, 8 in one, "\\d{9}" represents a number that can be 0~9, there are 9 bits.

if (Textutils.isempty (mobiles))

return false;

Else

Return mobiles.matches (Telregex);

}

Open a Mailing list page

The SDK of this interface comes with a style that is not unsightly and does not modify the necessary

private void Openfriendsui () {

Contactspage contactspage = new Contactspage ();

Contactspage.show (this);

}

Timer to prevent multiple request verification codes

private Button checking;

Public Timecount (Long millisinfuture, long Countdowninterval,button checking)

{

Super (Millisinfuture, countdowninterval);//parameter is the total length of time, and timing interval

this.checking = checking;

}

@Override

public void OnFinish ()

{

Trigger when timing is complete

Checking.settext ("Re-verification");

Checking.setclickable (TRUE);

Checking.setbackgroundcolor (0xff000000);

}

@Override

public void OnTick (long millisuntilfinished) {

Timing Process Display

Checking.setclickable (FALSE);

Checking.setbackgroundcolor (0XFFCCCCCC);

Checking.settext (millisuntilfinished/1000+ "re-authentication after second");

}

Key Features

The main function of the service is to send SMS verification code and get contact list

650) this.width=650; "alt=" Send SMS verification code and get contact list "border=" 0 "height=" 508 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ A7067e41-e949-922f-375d-b26374d94700/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" Send SMS verification code and get contact list "vspace= "0" width= "style=" margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle; font-weight:inherit;font-style:inherit;font-family:inherit;width:300px;height:508px; "/>

1. Send SMS Verification Code

Select the country, enter the phone number, you can get SMS verification code

Without the hassle of working with SMS platforms, the SDK is fast integrated and easy to integrate. Save yourself to talk to the operation of cooperation, talk about interfaces and other cumbersome steps

First try to send a text message function, will prompt you to be sent a mobile phone number, here is the hint you party B wrong, is a final determination, if not correct can be canceled small, re-enter the correct mobile phone number.

If you click OK then the SDK will submit a request to the server, and then the server according to the information you submitted to send text messages to the designated phone, so that the mobile phone to send a fixed-point SMS. Send a request to the server, ready to receive text messages, there is a buffer interface, because the sending of text messages, after all, also need a time interval, but also can not be continuously sent, so it became a spam message, also does not conform to our original intention.

650) this.width=650; "alt=" Send SMS Verification Code "border=" 0 "height=" 508 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ Db7ba83b-45ab-4b6a-8142-7544954e4a05/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" Send SMS Verification Code "vspace=" 0 "width = "Style=" Margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle;font-weight: inherit;font-style:inherit;font-family:inherit;width:300px;height:508px; "/>

650) this.width=650; "alt=" Send SMS Verification Code "border=" 0 "height=" 517 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ 036dc585-87cd-6d0c-5c41-c729b88d5da1/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" Send SMS Verification Code "vspace=" 0 "width = "Style=" Margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle;font-weight: inherit;font-style:inherit;font-family:inherit;width:300px;height:517px; "/>

Received the text message, the final result appeared, this is our ultimate result, SMS. Get the text message will have a verification code, we can in our app to achieve their own needs, to complete the corresponding functional effects.

650) this.width=650; "alt=" SMS Verification Code "border=" 0 "height=" 517 "hspace=" 0 "src=" http://ugc.qpic.cn/adapt/0/ d48ec556-12eb-f336-4e6b-e3ebdfc7ce07/800?pt=0&ek=1&kp=1&sce=0-12-12 "title=" SMS Verification Code "vspace=" 0 "width=" "Style=" Margin:0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle;font-weight:inherit ; font-style:inherit;font-family:inherit;width:300px;height:517px; "/>

2, Invite contacts friends to use the app, this is the result of getting contacts list, can read all the contacts on the phone, greatly facilitates the promotion of the app, quickly match contacts friends, build their own circle of friends.

650) this.width=650; "alt=" Contact "border=" 0 "height=" "" hspace= "0" src= "http://ds.devstore.cn/20150130/1422611724885 /%e5%9b%be%e7%89%8710.png?pt=5&ek=1&kp=1&sce=0-12-12 "title=" Contact "vspace=" 0 "width=" style= "margin : 0px;padding:0px;border-width:0px;border-style:none;vertical-align:middle;font-weight:inherit;font-style: inherit;font-family:inherit;width:300px;height:330px; "/>


This article is from the "indifferent" blog, please be sure to keep this source http://xingxin2066.blog.51cto.com/7271255/1762728

Mobandroid Free Verification SMS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.