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:
1if (Personal.islogin (This)) {2 Config.flag_login =True;3} 5 final Intent Intent; 6 if (Config.flag_ LOGIN) {new Intent (Splashactivity.this, Mainactivity. class); 8} else { 9 intent = new Intent (Splashactivity. This, loginactivity. class); 10}
Loginactivity
1PrivatevoidSetlistener () {2 Onclicklistener listener =NewOnclicklistener () {34@Override5PublicvoidOnClick (View v) {67if (v.getid () = =Buttonlogin.getid ()) {8 UserName =Edittextusername.gettext (). toString ();9 Password =Edittextpassword.gettext (). toString ();Ten loginurl =Config.login_rul;11if (Username.trim (). Equals ("")) {1213}Elseif (Username.trim (). Equals ("")) {1415}Else{16Login ();17}18}Elseif (v.getid () = =Buttonvisitor.getid ()) {Intent Intent =New Intent (loginactivity.This,Mainactivity.Class);21stStartActivity (Intent);Loginactivity.This. Finish ();23}2425}26};2728Buttonlogin.setonclicklistener (listener);29Buttonvisitor.setonclicklistener (listener);30}3132PrivatevoidLogin () {Logindialog dialog =New Logindialog (This);Progresscallback CallBack =NewProgresscallback () {3536@Override37PublicvoidAction () {The cookie =Personal.login (userName, password, loginurl);39if (Cookie! =Null) {Dbutils.addcookie (loginactivity.This, userName, cookies);Intent Intent =New Intent (loginactivity.This,Mainactivity.class); 43 startactivity (intent); this.finish (); Config.flag_login = true;}47 }48 }; 49 50 dialog.showprogressdialog ("login", "Logging in ..." , CallBack); 51 52}
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
Http://www.cnblogs.com/zhangtingkuo/p/3971546.html
"Android" Android Blog Park client (vii) LOGIN function