Android - How can I get the email from the online login and show it to next intent -
i created online login on mobile app, have online database, , use asynctask login. want display email user input app , display next intent how can that, how can pass email user input onpostexecute?
here code in onpostexecute when user logged in.
protected void onpostexecute(string result) { if (result.equals("login successfully!")) { toast.maketext(context, "welcome okshop", toast.length_short).show(); intent intent = new intent(context, main2activity.class); context.startactivity(intent); ((activity)context).finish(); } }
and here login url
else if (type.equals("login")) { string email = params[1]; string password = params[2]; try { url url = new url(login_url); httpurlconnection httpurlconnection = (httpurlconnection) url.openconnection(); httpurlconnection.setrequestmethod("post"); httpurlconnection.setdooutput(true); httpurlconnection.setdoinput(true); outputstream outputstream = httpurlconnection.getoutputstream(); bufferedwriter bufferedwriter = new bufferedwriter(new outputstreamwriter(outputstream, "utf-8")); string post_data = urlencoder.encode("email", "utf-8")+"="+urlencoder.encode(email, "utf-8")+"&" +urlencoder.encode("password", "utf-8")+"="+urlencoder.encode(password, "utf-8"); bufferedwriter.write(post_data); bufferedwriter.flush(); bufferedwriter.close(); outputstream.close(); inputstream inputstream = httpurlconnection.getinputstream(); bufferedreader bufferedreader = new bufferedreader(new inputstreamreader(inputstream, "iso-8859-1")); string result = ""; string line = ""; while ((line = bufferedreader.readline())!= null) { result+= line; } bufferedreader.close(); inputstream.close(); httpurlconnection.disconnect(); return result; } catch (malformedurlexception e) { e.printstacktrace(); } catch (protocolexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } return null; }
Comments
Post a Comment