http post - Android HttpClient.execute not working -
i have asynctask follow:
@override protected arraylist<string> doinbackground(string... params) { arraylist<string> result=new arraylist<>(); try { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost(constants.url); // add data list<basicnamevaluepair> namevaluepairs = new arraylist<basicnamevaluepair>( 2); namevaluepairs.add(new basicnamevaluepair("id",params[0])); httppost.setentity(new urlencodedformentity(namevaluepairs, "utf-8")); // execute http post request httpresponse response = httpclient.execute(httppost); httpentity httpentity = response.getentity(); inputstream = httpentity.getcontent(); // deal response here .... } catch (exception e) { log.e("debug", e + " " + e.getmessage()); } return result; }
however, on jellybean, after running app time, code runs httpclient.execute(httppost) , stops right there.
can me on that?
try things:
1.check network connection , server availability.
2.check have added internet permission manifest.
<manifest xlmns:android...> <uses-permission android:name="android.permission.internet" /> <application ... </manifest>
if didn't misunderstand "after time", saying never successes , stops there. because of permissions or net connection because request seems not return.
if runs yes not others, think must due server side.
i recommend using https://github.com/matessoftwaresolutions/androidhttprestservice
i promise push new commit android studio folder structure.
Comments
Post a Comment