android - How to Check Login Status? -
i have login app. after login, if correct, want show tabview with:
- my stats
- upload photo
- mapview
this code login activity
public class loginactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); string url, user, pwd, user_field, pwd_field; url = "http://myurl.com/login/"; user_field = "username"; pwd_field = "password"; user = "myuser"; pwd = "mypass"; list<namevaluepair> mylist = new arraylist<namevaluepair>(2); mylist.add(new basicnamevaluepair(user_field, user)); mylist.add(new basicnamevaluepair(pwd_field, pwd)); final httpparams params = new basichttpparams(); final httpclient client = new defaulthttpclient(params); final httppost post = new httppost(url); //final httpresponse end = null; //string endresult = null; button login_button = (button)findviewbyid(r.id.login_button); try { post.setentity(new urlencodedformentity(mylist)); } catch (unsupportedencodingexception e) { // todo auto-generated catch block e.printstacktrace(); } login_button.setonclicklistener(new onclicklistener(){ public void onclick(view v) { try { httpresponse response = client.execute(post); //httpresponse end = response; system.out.println(response.getstatusline()); } catch (clientprotocolexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } }); }
}
create login.php script can call on server , post authentication script , let script authentication , send result application.
so basically, application post authentication login.php script , script return application whether successful or not.
Comments
Post a Comment