android - how to navigate back to login page after successful register -
@override public void onclick(view v) { if(v == buttonregister){ registeruser(); } } private void registeruser() { ?*some code here*/ } private void register(string name, string email, string password, string phone ) { string urlsuffix = "?name="+name+"&email="+email+"&password="+password+"&phone="+phone; class registeruser extends asynctask<string, void, string> { progressdialog loading; @override protected void onpreexecute() { super.onpreexecute(); loading = progressdialog.show(signupactivity.this, "please wait",null, true, true); } @override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); toast.maketext(getapplicationcontext(), s, toast.length_short).show(); } @override protected string doinbackground(string... params) { string s = params[0]; bufferedreader bufferedreader = null; try { url url = new url(register_url+s); httpurlconnection con = (httpurlconnection) url.openconnection(); bufferedreader = new bufferedreader(new inputstreamreader(con.getinputstream())); string result; result = bufferedreader.readline(); return result; }catch(exception e){ return null; } } } registeruser ru = new registeruser(); ru.execute(urlsuffix); }
if moved login activity screen can use: @override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); toast.maketext(getapplicationcontext(), s, toast.length_short).show(); this.finish(); } otherwise can start new activity : @override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); toast.maketext(getapplicationcontext(), s, toast.length_short).show(); startactivity(new intent(signupactivity.this,loginactivity.class)); this.finish(); }
Comments
Post a Comment