Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.10 KB | None | 0 0
  1. private class JSONTask extends AsyncTask<String, Void, JSONObject>{
  2.         protected JSONObject doInBackground(String... params) {
  3.             JSONObject json_data=null;
  4.             try{
  5.                 HttpClient httpclient = new DefaultHttpClient();
  6.                 for(int i=0;i<counter;i++){
  7.                     Log.e("log_tag", myid.get(i));
  8.                     String s=myid.get(i);
  9.                     HttpPost httppost = new HttpPost("http://photogiuseppe.altervista.org/mydogs.php?id="+s);
  10.                     HttpResponse response = httpclient.execute(httppost);
  11.                     HttpEntity entity = response.getEntity();
  12.                     String body = EntityUtils.toString(entity);
  13.                     JSONObject result = new JSONArray(body).getJSONObject(0);
  14.                     is[i]=entity.getContent();
  15.                 }//fine ciclo for
  16.             }//chiusura try
  17.             catch(Exception e){
  18.                 Log.e("log_tag", "Errore in http connection"+e.toString());
  19.                 e.printStackTrace();
  20.             }
  21.  
  22.                 return json_data;
  23.             }//chiusura doInBackground
  24.        
  25.         protected void postExecute(JSONObject json_data){}
  26.          
  27.         protected void onPostExecute(JSONObject json_data) {
  28.             postExecute(json_data);
  29.         }
  30.        
  31.     }//chiusura JSONTask
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement