no any response when use httpclient in AsyncTask
<p>i want to get data from my server with AsyncTask and then extract some and send to another location and get more info from that</p>

<p>for first section I'm using from this code for run my AsyncTask method and Cancel AsyncTask after some time (for no response...)</p>

<pre><code>new MySecendServer(link, param,mInstagramSession).execute();
final ProgressDialog pd2 = new ProgressDialog(testActivity.this);
pd2.show();
final Timer tm = new Timer();
tm.scheduleAtFixedRate(new TimerTask() {
    public void run() {
        runOnUiThread(new Runnable() {
            public void run() {
                 count++;
                            if (count == 30) {
                                pd2.cancel();
                                tm.cancel();
                                new MySecendServer(.....) .cancel(true); }

            }
        });

        }
    }, 1, 1000); 
</code></pre>

<p>then after get data from my server i try to get more info with this code but i don't get any response or exception i test this code in doInBackground And onPostExecute and no any diffrent and no any response </p>

<pre><code>        try {
        String requestUrl = "https://api.instagram.com/v1/users/";
        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(requestUrl);
        HttpResponse httpResponse = httpClient.execute(httpGet);
        HttpEntity httpEntity = httpResponse.getEntity();
        if (httpEntity == null) {
            throw new Exception("Request returns empty result");
        }
        InputStream stream = httpEntity.getContent();
        String response = StringUtil.streamToString(stream);
        if (httpResponse.getStatusLine().getStatusCode() != 200) {
            throw new Exception(httpResponse.getStatusLine().getReasonPhrase());
        }
    } catch (Exception ex) {}
</code></pre>

<p>now anyone can give me reason or any suggest for do this work ?
thanks</p>

<p><strong>Update :</strong></p>

<p>I found exception here :</p>

<pre><code>HttpResponse httpResponse   = httpClient.execute(httpGet);
</code></pre>

<p>and message is :</p>

<blockquote>
  <p>cause NetworkOnMainThreadException  (id=831620140512)</p>
</blockquote>

<p><strong>Update 2 :</strong>
My first AsyncTask</p>

<pre><code>public class MySecendServerClass extends AsyncTask {

    private String link="";
    private String [][]pparams;
    private InstagramUser IG_User;
    private InstagramSession IG_Session;

    public MySecendServerClass(String link,String [][]params,InstagramSession user){
        this.link=link;
        this.pparams=params;
        this.IG_Session = user;

    }


    @Override
    protected String doInBackground(Object... arg0) {

        String data="";
        try{
        if(pparams!=null){
            for(int i=0;i&lt;pparams.length;i++){
                    if(i!=0){
                        data+="&amp;";
                    }
                    data+=URLEncoder.encode(pparams[i][0],"UTF8")+"="+URLEncoder.encode(pparams[i][1],"UTF8");

            }
        }
        URL mylink=new URL(link);

        URLConnection connect=mylink.openConnection();
        connect.setDoOutput(true);
        OutputStreamWriter wr=new OutputStreamWriter(connect.getOutputStream());
        wr.write(data);
        wr.flush();
        BufferedReader reader=new BufferedReader(new InputStreamReader(connect.getInputStream()));
        StringBuilder sb=new StringBuilder();
        String line=null;
        while((line=reader.readLine())!=null){
            sb.append(line);
        }
        Log.d("sssss",sb.toString());
        return sb.toString();
        }
        catch(Exception ex){

        }
        return null;
    }

    @Override
    protected void onPostExecute(Object tr) {
        super.onPostExecute(tr);            
        String result = (String)tr;
        try{
        JSONObject json = new JSONObject(result);
        JSONArray jArray = json.getJSONArray("followlist");
        JSONObject jObject = jArray.getJSONObject(0);
        String client_id=jObject.getString("client_id");
        GrtUserProfile(client_id);

        }
        catch(Exception ex){

        }
    }
}
</code></pre>

<p><strong>Solve Problem With this Code :</strong></p>

<pre><code>public void GrtUserProfile(String Cid) {

    String requestUrl= "https://api.instagram.com/v1/users/"+Cid+"/"+"&amp;access_token="+mInstagramSession.getAccessToken();

    new HTTPRequestClass().execute(requestUrl);

}

 class HTTPRequestClass extends AsyncTask&lt;String, Void, String&gt; {



    protected String doInBackground(String... urls) {
         try {
                String url = urls[0];
                HttpGet httpRequest = new HttpGet(url);
                HttpClient httpclient = new DefaultHttpClient();
                HttpResponse httpResponse = httpclient.execute(httpRequest);
                HttpEntity httpEntity       = httpResponse.getEntity();
                if (httpEntity == null) {
                    throw new Exception("Request returns empty result");
                }
                InputStream stream      = httpEntity.getContent();      
                String response = StringUtil.streamToString(stream);
                if (httpResponse.getStatusLine().getStatusCode() != 200) {
                    throw new Exception(httpResponse.getStatusLine().getReasonPhrase());

                }
                return response;
            } catch (Exception e) {
                  return "";
            }

    }
    protected void onPostExecute(String Response) {
        Log.i("Response", Response);
    }
 }
</code></pre>