Import android.content.Intent;
Import Android.os.Bundle;
Import Android.os.Handler;
Import Android.support.v7.app.ActionBar;
Import android.support.v7.app.ActionBarActivity;
Import Android.text.TextUtils;
Import Android.util.Log;
Import Android.view.View;
Import Android.view.View.OnClickListener;
Import Android.widget.Button;
Import Android.widget.EditText;
Import Cn.bmob.v3.BmobUser;
Import cn.bmob.v3.exception.BmobException;
Import Cn.bmob.v3.listener.LogInListener;
Import Cn.bmob.v3.listener.RequestSMSCodeListener;
Import Com.chencheng.model.User;
Import Com.chencheng.utils.LoginStatus;
Import Com.chencheng.utils.MyToast;
Import Com.xinbo.utils.SMSCodeBMobUtils;
public class Shoujidengruactivity extends Actionbaractivity {
Private EditText Et_number;
Private EditText Et_code;
Private Button Yanzhengma_fasong;
Private Button Btn_find_back_yanzhengbindengl;
private String number;
Private String Code;
Private String Msmsid;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.LAYOUT.ACTIVITY_SHOUJI_DENGRU);
Initactionbar ();
Initui ();
}
private void Initui () {
Et_number= (EditText) Findviewbyid (r.id.mobile);
Et_code= (EditText) Findviewbyid (r.id.yanzhengma_val);
Yanzhengma_fasong= (Button) Findviewbyid (R.id.yanzhengma_fasong);
Yanzhengma_fasong.setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View v) {
TODO auto-generated Method Stub
Number = Et_number.gettext (). toString ();
1. Call the request verification Code interface
Smscodebmobutils.requestsmscode (shoujidengruactivity.this, number, new Requestsmscodelistener () {
@Override
public void-DONE (Integer smsid,bmobexception ex) {
if (! Textutils.isempty (number)) {
if (ex==null) {//Verification code sent successfully
Verification code sent successfully
Msmsid = smsid+ "";
Mytoast.maketext (Shoujidengruactivity.this, "Verification code sent successfully, SMS ID:" + smsId);//used to query this text message send details
Daojishi (Yanzhengma_fasong);
}
else{
Mytoast.maketext (Shoujidengruactivity.this, "Verification code failed to send");
}
}else{
Et_number.seterror ("Please enter a phone number");
}
}
});
}
});
Btn_find_back_yanzhengbindengl= (Button) Findviewbyid (R.ID.BTN_FIND_BACK_YANZHENGBINDENGL);
Btn_find_back_yanzhengbindengl.setonclicklistener (New Onclicklistener () {
@Override
public void OnClick (View v) {
TODO auto-generated Method Stub
Signorloginbyphonenumber ();
}
});
}
private void Initactionbar () {
ActionBar ActionBar = Getsupportactionbar ();
Actionbar.setdisplayhomeasupenabled (TRUE);
Actionbar.setbackgrounddrawable (Getresources (). Getdrawable (
R.color.action_white));
Actionbar.settitle ("Mobile phone quick login");
}
@Override
public Boolean onsupportnavigateup () {
Finish ();
return Super.onsupportnavigateup ();
}
private void Signorloginbyphonenumber () {
Number = Et_number.gettext (). toString ();
Code = Et_code.gettext (). toString ();
if (! Textutils.isempty (number) &&! Textutils.isempty (code)) {
2, using the mobile phone number and SMS verification code to register a key login
Bmobuser.signorloginbymobilephone (this, number, code, new Loginlistener<user> () {
@Override
public void-Done (user user, bmobexception e) {
TODO auto-generated Method Stub
if (user!=null) {
Mytoast.maketext (Shoujidengruactivity.this, "login Successful");
LOG.I ("Shoujidengru", "" "+user.getusername () +"-"+user.getobjectid () +"-"+user.getpassword ());
Loginstatus.getinstance (). Sethaslogin (True);
Intent intent=new Intent (shoujidengruactivity.this,mainactivity.class);
Intent.putextra ("Flag", "Haslogin");
StartActivity (Intent);
}else{
Mytoast.maketext (shoujidengruactivity.this, "error code:" +e.geterrorcode () + ", Error Reason:" +e.getlocalizedmessage ());
}
}
});
}else{
Mytoast.maketext (Shoujidengruactivity.this, "Please enter phone number and verification code");
}
}
private void Daojishi (Final button button) {
New Handler (). postdelayed (New Runnable () {
int i=60;
@Override
public void Run () {
if (i>0)
{
Button.settext (i+ "s");
Button.setenabled (FALSE);
i--;
LOG.E ("Run", i+ "");
New Handler (). postdelayed (this, 1000);
}
if (i==0)
{
Button.settext ("Send Verification Code");
Button.setenabled (TRUE);
}
}
}, 1000);
}
}
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/91/wKioL1WhMFGBFaCNAACfkjwvRCY991.jpg "style=" float: none; "title=" Income mobile phone number "alt=" Wkiol1whmfgbfacnaacfkjwvrcy991.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6F/91/wKioL1WhMLfgUJDIAAHAVoyZV9U058.jpg "title=" SMS received Verification Code "alt=" Wkiol1whmlfgujdiaahavoyzv9u058.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/91/wKioL1WhMFOhFdu8AADaDIuuNOw627.jpg "style=" float: none; "title=" message sent successfully "alt=" Wkiol1whmfohfdu8aadadiuunow627.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/91/wKioL1WhMFThE1oRAAEvD0d8DIc086.jpg "style=" float: none; "Title=" landed successfully "alt=" Wkiol1whmfthe1oraaevd0d8dic086.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/94/wKiom1WhLoCinGU3AADsdJFlCHE101.jpg "style=" float: none; "Title=" Bomb on the user table add a column "alt=" Wkiom1whlocingu3aadsdjflche101.jpg "/>
CC_ Program User module for the use of mobile authentication Code direct Login implementation