How Android integrates Aurora SMS Verification _android

Source: Internet
Author: User
Tags gettext

Create a new empty project with the Android Studio tool first.

Step One (Get Appkey)

1. On the Aurora official platform to create new text messaging applications (according to the requirements of the package name and application name completed)


2. Get Jpush_appkey


Step Two (import third party libraries and so files)

1. Open applications with Android Studio

2. Toggle Application Status Android to project status


3. Copy the corresponding jar file into the Libs folder and as libraries


Step three (initialization and invocation)

1. New Application Initialization

public class MyApp extends application { 
  @Override public 
  void OnCreate () { 
    super.oncreate (); 
    Smssdk.getinstance (). Setdebugmode (true); 
    Smssdk.getinstance (). INITSDK (this); 
  } 
 

2. Invoking in the activity

public class Mainactivity extends baseactivity {edittext edit_name; 
  EditText edit_pwd; 
  EditText SMS; 
  String name; 
  String pwd; 
  Button get_sms; 
  Button Btn_login; Private Handler Handler = new Handler () {@Override public void Handlemessage (msg) {Super.handle 
      Message (msg); Switch (msg.what) {case 1:toast.maketext (Mainactivity.this, msg.obj.toString (), Toast.length_short). 
          Show (); 
        Break 
          Case 2:toast.maketext (Mainactivity.this, msg.obj.toString (), Toast.length_short). Show (); 
        Break 
          Case 3:toast.maketext (Mainactivity.this, msg.obj.toString (), Toast.length_short). Show (); 
        Break 
          Case 4:toast.maketext (Mainactivity.this, msg.obj.toString (), Toast.length_short). Show (); 
      Break 
 
  } 
    } 
  }; 
    @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);Setcontentview (R.layout.activity_main); 
  Init (); 
    private void Init () {edit_name = (edittext) Findviewbyid (r.id.edit_name); 
    Edit_pwd = (edittext) Findviewbyid (R.ID.EDIT_PWD); 
    SMS = (edittext) Findviewbyid (r.id.sms); 
    Get_sms = (Button) Findviewbyid (r.id.get_sms); 
    Btn_login = (Button) Findviewbyid (R.id.btn_login); 
    Get_sms.setonclicklistener (New Getsmsclicklistener ()); 
  Btn_login.setonclicklistener (New Loginclicklistener ());  The public class Getsmsclicklistener implements View.onclicklistener {@Override public void OnClick (View 
      View) {name = Edit_name.gettext (). toString (). Trim (); 
      PWD = Edit_pwd.gettext (). toString (). Trim (); 
      if (Name.equals ("")) {Edit_name.requestfocus (); 
      else if (Pwd.equals ("")) {Edit_pwd.requestfocus (); 
              else {new Thread (new Runnable () {@Override public void run () {try { Getsmscode (NamE, PWD); 
            catch (Exception ex) {ex.printstacktrace (); 
      }}). Start (); }} private void Getsmscode (string name, string pwd) {GetCode (this.name, this.pwd, new Getcodelis 
          Tener () {@Override public void getcodesuccess (String s) {msg = Message.obtain (); 
          Msg.obj = s; 
          Msg.what = 1; 
        Handler.sendmessage (msg); 
          @Override public void Getcodefail (String s) {msg = Message.obtain (); 
          Msg.obj = s; 
          Msg.what = 2; 
        Handler.sendmessage (msg); 
  } 
      }); public class Loginclicklistener implements View.onclicklistener {@Override public void OnClick (View VI 
      EW) {Final String code = Sms.gettext (). toString (). Trim (); 
      Name = Edit_name.gettext (). toString (). Trim (); 
      PWD = Edit_pwd.gettext (). toString (). Trim (); If (Name.equals ("")) 
      {Edit_name.requestfocus (); 
      else if (Pwd.equals ("")) {Edit_pwd.requestfocus (); 
      else if (Code.equals ("")) {Sms.requestfocus (); 
              else {new Thread (new Runnable () {@Override public void run () {try { 
            Checksmscode (name, pwd, code); 
            catch (Exception ex) {ex.printstacktrace (); 
      }}). Start (); }} private void Checksmscode (string name, string pwd, String code) {Checkcode (this.name, This.pwd, C  Ode, new Checkcodelistener () {@Override public void checkcodesuccess (String s) {msg 
          = Message.obtain (); 
          Msg.obj = s; 
          Msg.what = 3; 
        Handler.sendmessage (msg); 
          @Override public void Checkcodefail (String s) {msg = Message.obtain (); 
         Msg.obj = s; Msg.what = 4; 
        Handler.sendmessage (msg); 
 
  } 
      }); 
 } 
 
}

Step four (fill in the configuration file)

1. Configure Application Permissions

<uses-permission android:name= "Android.permission.INTERNET"/> 
<uses-permission android:name= " Android.permission.READ_PHONE_STATE "/> 
<uses-permission android:name=" android.permission.ACCESS_WIFI_ State "/> 
<uses-permission android:name=" Android.permission.ACCESS_NETWORK_STATE "/> 

2. Configuration meta (Appkey from the new corresponding application on the platform)

<meta-data android:name= "Jpush_appkey" android:value= "You Jpush_appkey"/>

Step Five (Debug)

1. Click the Get Password button to get the message


The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.