web - How do I receive value in website from android phone -
i sending value android phone website. website registered online through free sources.
the code is,
public class httpstorage extends asynctask{ protected void onpreexecute() { super.onpreexecute(); } protected void onpostexecute(integer result) { } public void postdata() { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://pavithrakrishnakumar.simplesite.com/"); try { list <namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("idtoken1", "username")); namevaluepairs.add(new basicnamevaluepair("idtoken2", "password")); httppost.setentity(new urlencodedformentity(namevaluepairs)); httpresponse response = httpclient.execute(httppost); } catch (clientprotocolexception e) { } catch (ioexception e) { } } @override protected object doinbackground(object... arg0) { postdata(); return null; } }
now not getting error in android side. how retrieve value in above mentioned site
public void postdata() { // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://pavithrakrishnakumar.simplesite.com/"); try { list <namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("idtoken1", "username")); namevaluepairs.add(new basicnamevaluepair("idtoken2", "password")); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); if(response != null) { int statuscode = response.getstatusline().getstatuscode(); if(statuscode==httpstatus.sc_ok) { string strresponse = entityutils.tostring(response.getentity()); } } } catch (clientprotocolexception e) { // todo auto-generated catch block } catch (ioexception e) { // todo auto-generated catch block } }
Comments
Post a Comment