Create a new empty project with the Android Studio tool first.
Step One (Get Appkey)
1. Create a new SMS app on the Aurora website (please fill in the package name and application name as required)
2. Get Jpush_appkey
Step Two (import third-party libraries and so files)
1. Open the app with Android studio
2. Switch app status Android to project status
3. Copy the corresponding jar file into the Libs folder and then as libraries
Step three (Initialize and invoke)
1. New Application Initialization
public class MyApp extends application { @Override public void OnCreate () { super.oncreate (); Smssdk.getinstance (). Setdebugmode (true); Smssdk.getinstance (). INITSDK (this);} }
2. Calling in 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 (Message msg) {Supe R.handlemessage (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 ()); } public class Getsmsclicklistener implements View.onclicklistener {@Override the public void OnClick (View V Iew) {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 Getcodel Istener () {@Override public void getcodesuccess (String s) {Message msg = Message.obtain (); Msg.obj = s; Msg.what = 1; Handler.sendmessage (msg); } @Override public void Getcodefail (String s) {Message msg = MESSAGE.OBT Ain (); Msg.obj = s; Msg.what = 2; Handler.sendmEssage (msg); } }); } public class Loginclicklistener implements View.onclicklistener {@Override the 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, code, new Che Ckcodelistener () {@Override public void checkcodesuccess (String s) {Mes Sage msg = Message.obtain (); Msg.obj = s; Msg.what = 3; Handler.sendmessage (msg); } @Override public void Checkcodefail (String s) {Message msg = MESSAGE.O Btain (); Msg.obj = s; Msg.what = 4; Handler.sendmessage (msg); } }); }}
Step four (fill in the configuration file)
1. Configure app 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. Configure meta (Appkey from a new 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 SMS message
How Android learns to integrate Aurora SMS verification