"Android" Android Blog Park client (vii) LOGIN function

Source: Internet
Author: User

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

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.