Title, but only simple login function, the operation can be done after the successful login has not been implemented.
The main principle of login is to obtain the cookies and keep the data in the database. The way you can sign in with HttpClient has already been written in another blog post, and you won't be repeating it here.
Blog Address: http://www.cnblogs.com/zhangtingkuo/p/3968450.html
Sign-In Process:
The code is simple:
Splashactivity:
1 if(Personal.islogin ( This)) {2Config.flag_login =true;3 }4 5 FinalIntent Intent;6 if(config.flag_login) {7Intent =NewIntent (splashactivity. This, Mainactivity.class);8}Else {9Intent =NewIntent (splashactivity. This, Loginactivity.class);Ten}
Loginactivity
1 Private voidSetlistener () {2Onclicklistener listener =NewOnclicklistener () {3 4 @Override5 Public voidOnClick (View v) {6 7 if(V.getid () = =Buttonlogin.getid ()) {8UserName =Edittextusername.gettext (). toString ();9Password =Edittextpassword.gettext (). toString ();TenLoginurl =Config.login_rul; One if(Username.trim (). Equals ("")) { A -}Else if(Username.trim (). Equals ("")) { - the}Else { - login (); - } -}Else if(V.getid () = =Buttonvisitor.getid ()) { +Intent Intent =NewIntent (loginactivity. This, -Mainactivity.class); + startactivity (intent); ALoginactivity. This. Finish (); at } - - } - }; - - Buttonlogin.setonclicklistener (listener); in Buttonvisitor.setonclicklistener (listener); - } to + Private voidLogin () { -Logindialog dialog =NewLogindialog ( This); theProgresscallback CallBack =NewProgresscallback () { * $ @OverridePanax Notoginseng Public voidaction () { -Cookie =personal.login (userName, password, loginurl); the if(Cookie! =NULL) { +Dbutils.addcookie (loginactivity. This, userName, cookies); AIntent Intent =NewIntent (loginactivity. This, theMainactivity.class); + startactivity (intent); -Loginactivity. This. Finish (); $Config.flag_login =true; $ } - } - }; the -Dialog.showprogressdialog ("Login", "Logging in ...", callBack);Wuyi the}
The login effect is as follows:
The first time the project, the entire structure is difficult to grasp, the code structure is always modified. In order to have a more intuitive understanding, summed up the entire software running process, does not include Actionbar in the function.
Project Address: Https://github.com/ZhangTingkuo/AndroidCnblogs
Android Blog Park Client (vii) LOGIN function