Android Auto Login with remember password

Source: Internet
Author: User

//Get Instance ObjectSP = This. Getsharedpreferences ("UserInfo", context.mode_world_readable); REM_PW=(CheckBox) Findviewbyid (R.id.cb_mima); Auto_login=(CheckBox) Findviewbyid (R.id.cb_auto);//to remember the state of a password multi-box        if(Sp.getboolean ("Ischeck",false)) {            //set default is record password statusRem_pw.setchecked (true); Username.settext (Sp.getstring ("User_name", "" ")); LOG.V ("Testtest", sp.getstring ("user_name", "" ")); Password.settext (Sp.getstring ("PASSWORD", "" ")); LOG.V ("Testtest", Sp.getstring ("PASSWORD", "" ")); //determine the status of auto-login multi-marquee            if(Sp.getboolean ("Auto_ischeck",false)) {                //Set DEFAULT is auto sign-in statusAuto_login.setchecked (true); //Jump InterfaceIntent Intent =NewIntent (loginactivity. This, Mainactivity.class); Loginactivity. This. StartActivity (Intent); }        }//Login Success And remember Password box is selected to save user information                        if(rem_pw.ischecked ()) {//Remember the user name, password,Editor Editor =Sp.edit (); Editor.putstring ("User_name", user); Editor.putstring ("PASSWORD", PWD);                        Editor.commit (); }//Monitor Remember password Multi box button eventRem_pw.setoncheckedchangelistener (NewOncheckedchangelistener () { Public voidOnCheckedChanged (Compoundbutton Buttonview,BooleanisChecked) {                if(rem_pw.ischecked ()) {System.out.println ("Remember that the password is selected"); LOG.V ("Testtest", "Remember Password is selected"); Sp.edit (). Putboolean ("Ischeck",true). commit (); }                Else{System.out.println ("Remember that the password is not selected"); LOG.V ("Testtest", "Remember that the password is not selected"); Sp.edit (). Putboolean ("Ischeck",false). commit ();        }            }        }); //Listen for auto-logon Multi-marquee eventsAuto_login.setoncheckedchangelistener (NewOncheckedchangelistener () { Public voidOnCheckedChanged (Compoundbutton Buttonview,BooleanisChecked) {                if(auto_login.ischecked ()) {System.out.println ("Automatic Logon is selected"); LOG.V ("Testtest", "Automatic Logon is selected"); Sp.edit (). Putboolean ("Auto_ischeck",true). commit (); }                Else{System.out.println ("Automatic logon is not selected"); LOG.V ("Testtest", "Automatic login not selected"); Sp.edit (). Putboolean ("Auto_ischeck",false). commit ();    }            }        }); }

Sharedpreferences

Getboolean (String key, Boolean defvalue): Get Boolean data

Parameter Description: Boolean defvalue does not set this value, there is no  default return value in the configuration file

Android Auto Login with remember password

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.