@Override
protected Void doInBackground(Void... params) {
try {
HttpClient lClient = new DefaultHttpClient();
HttpGet lGetMethod = new HttpGet(URL);
HttpResponse lResp = null;
lResp = lClient.execute(lGetMethod);
ByteArrayOutputStream lBOS = new ByteArrayOutputStream();
String lInfoStr = null;
JSONObject lYouTubeResponse = null;
try {
lResp.getEntity().writeTo(lBOS);
lInfoStr = lBOS.toString("UTF-8");
lYouTubeResponse = new JSONObject(lInfoStr);
JSONArray trackArray = lYouTubeResponse
.getJSONArray("results");
for (int i = 0; i < trackArray.length(); i++) {
JSONObject tracksObj = trackArray.getJSONObject(i);
String Artist = tracksObj.optString("artistName", null);
artistsList.add(Artist);
String Album = tracksObj.optString("collectionName",
null);
albumsList.add(Album);
String albumId = tracksObj.optString("collectionId",
null);
albumsIdList.add(albumId.trim());
}
} catch (Exception e) {
Log.i("exception 1", e.toString());
} catch (OutOfMemoryError outofmemoryerror) {
outofmemoryerror.printStackTrace();
}
} catch (Exception e) {
Log.i("exception 2", e.toString());
}
return null;
}
protected Void doInBackground(Void... params) {
try {
HttpClient lClient = new DefaultHttpClient();
HttpGet lGetMethod = new HttpGet(URL);
HttpResponse lResp = null;
lResp = lClient.execute(lGetMethod);
ByteArrayOutputStream lBOS = new ByteArrayOutputStream();
String lInfoStr = null;
JSONObject lYouTubeResponse = null;
try {
lResp.getEntity().writeTo(lBOS);
lInfoStr = lBOS.toString("UTF-8");
lYouTubeResponse = new JSONObject(lInfoStr);
JSONArray trackArray = lYouTubeResponse
.getJSONArray("results");
for (int i = 0; i < trackArray.length(); i++) {
JSONObject tracksObj = trackArray.getJSONObject(i);
String Artist = tracksObj.optString("artistName", null);
artistsList.add(Artist);
String Album = tracksObj.optString("collectionName",
null);
albumsList.add(Album);
String albumId = tracksObj.optString("collectionId",
null);
albumsIdList.add(albumId.trim());
}
} catch (Exception e) {
Log.i("exception 1", e.toString());
} catch (OutOfMemoryError outofmemoryerror) {
outofmemoryerror.printStackTrace();
}
} catch (Exception e) {
Log.i("exception 2", e.toString());
}
return null;
}
No comments:
Post a Comment