Android Studio uses its own loginactivity template to create a login interface
Login interface Features:
1, remember the form account password, and automatically login
//obtaining an SP instance ObjectSP = This. Getsharedpreferences ("UserInfo", context.mode_world_readable); //If you have logged in, log in directly if(Sp.getboolean ("Isload",false) {Intent Intent=NewIntent ( This, Mainactivity.class); Intent.putextra ("USER", sp.getstring ("user_name", "" ")); StartActivity (Intent); This. Finish ();//Close the login screen}
2. Achieve Login Success Interface Jump
@Overrideprotected voidOnPostExecute (FinalBoolean Success) {Mauthtask=NULL; ShowProgress (false); if(Success) {//Call UihandlerMessage msg =NewMessage (); Uihandler.sendmessage (msg); Finish (); } Else{mpasswordview.seterror (getString (R.string.error_incorrect_password)); Mpasswordview.requestfocus (); } } PrivateHandler uihandler=NewHandler () {@Override Public voidhandlemessage (Message msg) {//Remember the user name, password,Sharedpreferences.editor Editor =Sp.edit (); Editor.putstring ("User_name", Memail); Editor.putstring ("PASSWORD", Mpassword); Editor.putboolean ("Isload",true); Editor.commit (); //activity JumpIntent Intent =NewIntent (loginactivity. This, Mainactivity.class); StartActivity (Intent); } };
Login Jump Reference: Android Note---loginactivity extends finalactivity
asynctask Reference:Android Asynctask Introduction
Remember password reference: Android Remember Password and automatic login interface implementation (Sharedpreferences usage)
Handler method Reference: Android.os.handler
Android--loginactivity Template Login