android - unable to parse json data from a given link -


my code this. have used asynctask , tried collect data in doinbackground. on running code giving error java.lang.runtimeexception: error occured while executing doinbackground(). when tried check upto line code running found statement code not executing httpresponse in doinbackground. can tell me wrong dong. thanks.

package com.example.parser;      import java.io.ioexception;      import org.apache.http.httpentity;     import org.apache.http.httpresponse;     import org.apache.http.statusline;     import org.apache.http.client.clientprotocolexception;     import org.apache.http.client.httpclient;     import org.apache.http.client.methods.httpget;     import org.apache.http.impl.client.defaulthttpclient;     import org.apache.http.util.entityutils;      import android.app.activity;     import android.os.asynctask;     import android.os.bundle;     import android.util.log;     import android.view.menu;     import android.view.menuitem;      public class mainactivity extends activity {          @override         protected void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);             setcontentview(r.layout.activity_main);             new requesttask().execute("http://api.frankly.me/dubs/audiocategories");         }          @override         public boolean oncreateoptionsmenu(menu menu) {             // inflate menu; adds items action bar if present.             getmenuinflater().inflate(r.menu.main, menu);             return true;         }          @override         public boolean onoptionsitemselected(menuitem item) {             // handle action bar item clicks here. action bar             // automatically handle clicks on home/up button, long             // specify parent activity in androidmanifest.xml.             int id = item.getitemid();             if (id == r.id.action_settings) {                 return true;             }             return super.onoptionsitemselected(item);         }     }     class requesttask extends asynctask<string, void, string>{         //httpget req;         //httpclient httpclient;         //httpresponse res=null;         @override         protected string doinbackground(string... params) {             // todo auto-generated method stub               string data=null;              try {                 httpget req=new httpget(params[0]);                 httpclient httpclient=new defaulthttpclient();                 log.d("1",params[0]);                 httpresponse res=httpclient.execute(req);                  int status=res.getstatusline().getstatuscode();                 log.d("httpresponse",integer.tostring(status));                 httpentity entity = res.getentity();                 data = entityutils.tostring(entity);                 log.d("data",data);             } catch (clientprotocolexception e) {                 // todo auto-generated catch block                 log.d("e",e.getlocalizedmessage());             } catch (ioexception e) {                 // todo auto-generated catch block                 log.d("e2",e.getlocalizedmessage());             }              return data;         }         @override         protected void onpostexecute(string result) {             // todo auto-generated method stub             super.onpostexecute(result);         }      } 

logcat coming is:enter image description here


Comments