Cannot post variable from android client to php server -


i develop android code transmit , received between android apps , php. received part based on json, working. have tested set variable manually in php code. however, when have posted variable android php, cannot receive it. can tell me problem ?

@override protected string doinbackground(void... params) {       arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>();       namevaluepairs.add(new basicnamevaluepair("username", <your username here>));       try {         httpclient httpclient = new defaulthttpclient();         httppost httppost = new httppost(<your url php file>);         httppost.setentity(new urlencodedformentity(namevaluepairs, "utf-8"));         httpresponse response = httpclient.execute(httppost); // execute post url         string st = entityutils.tostring(response.getentity()); // result php web         log.d(tk_configuration.tag, "in try loop" + st); // still executing         finalresult = st; // should register variable finalresult;      } catch (exception e) {         log.d(tk_configuration.tag, "connection error : " + e.tostring());     }     return "ok";  }  protected void onpostexecute(string result) {     super.onpostexecute(result);      // after that, have final result , process here     // below simple code, please change     if(finalresult.equals("1")){         toast.maketext(context, context.getresources().getstring(r.string.upload_bike_success), toast.length_short).show();      }     else{         toast.maketext(context, context.getresources().getstring(r.string.upload_bike_fail), toast.length_short).show();     }     // end } 


please try this, , 1 more point, should use gson library decode json java object after got json string server.
note: replace tk_configuration.tag << tag.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -