You are running network related operation on the ui thread which is not possible. Use a Thread
or Asynctask
.
Post Honeycomb you will get NetworkOnMainThreadException
This is only thrown for applications targeting the Honeycomb SDK or
higher. Applications targeting earlier SDK versions are allowed to do
networking on their main event loop threads, but it's heavily
discouraged. See the document Designing for Responsiveness.
http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html
AsyncTask docs
http://developer.android.com/reference/android/os/AsyncTask.html
Edit
new TheTask().execute();
Then
public void getJson()
{
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpGet request = new HttpGet("http://tusyad2014.org/akb_api/hastalarimiza_ozel.json");
try
{
HttpResponse response = httpclient.execute(request);
HttpEntity resEntity = response.getEntity();
String _response=EntityUtils.toString(resEntity);
Log.e("sdf",_response);
} catch (Exception e) {
Log.e("sdf","");
}
}
class TheTask extends AsyncTask <String,Void,Void>
{
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
}
@Override
protected Void doInBackground(String... params) {
getJson();
return null;
}
}
}
Log
08-15 15:05:26.745: E/sdf(21197): [{"id":"1","name":"Ayakta Åekil BozukluÄu- Kemik Ãıkıntısı- Halluks Valgus - Halluks Rijitus"},{"id":"2","name":"Ãekiç Parmak"},{"id":"3","name":"DoÄumsal El, Ayak, Ãst Ekstremite Anamolileri, Eksiklikleri, Åekil Bozuklukları"},{"id":"4","name":"DoÄum Felci- DoÄum sonrası Beyin Felci, Spastisite"},{"id":"5","name":"Kapalı omuz, dirsek, el bileÄi ameliyatları- ARTROSKOPÄ°K cerrahi giriÅimler"},{"id":"6","name":"Ortopedi de PRP ( trombositten zengin plazma) uygulamaları"},{"id":"7","name":"Kırık kaynama gecikmesi, kaynamamaları ve ultrason tedavisi"},{"id":"8","name":"El bileÄi kırıkları, radius ve ulna alt uç kırıkları, skafoid kırıkları"},{"id":"9","name":"Humerus kırıkları, radial sinir sorunları, kaynamamaları"},{"id":"10","name":"Eldeki kistler,Ganglion kistleri"},{"id":"11","name":"Dirsek aÄrısı,Tenisçi dirseÄi, Golfçü dirseÄi"},{"id":"12","name":"Elde uyuÅma, karıncalanma, iÄnelenme, aÄrı"},{"id":"13","name":"Pleksus ve sinir yaralanmaları"},{"id":"14","name":"Ãnkol Kemik (Radius ve Ulna) Kaynamamaları"},{"id":"15","name":"Femur BaÅı Avasküler Nekrozu"},{"id":"16","name":"Tetik Parmak"},{"id":"17","name":"BaÅparmak Tendonlarının SıkıÅması (De Quervain HastalıÄı)"},{"id":"18","name":"Omuz AÄrısı ve Hareket KısıtlılıÄı"},{"id":"19","name":"DoÄumsal Tibia Kaynamaması (Konjenital Tibia Psödoartrozu)"}]