Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyTask extends AsyncTask<String, Void, String> {
- HttpURLConnection urlConnection = null;
- BufferedReader reader = null;
- String resultJson = "";
- @Override
- public String doInBackground(String... urls) {
- try {
- URL url = new URL(**LINK**);
- urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setRequestMethod("GET");
- urlConnection.connect();
- InputStream inputStream = urlConnection.getInputStream();
- StringBuffer buffer = new StringBuffer();
- reader = new BufferedReader(new InputStreamReader(inputStream));
- String line;
- while ((line = reader.readLine()) != null) {
- buffer.append(line);
- }
- resultJson = buffer.toString();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return resultJson;
- }
- @Override
- public void onPostExecute(String strJson) {
- super.onPostExecute(strJson);
- try {
- //SONObject dataJsonObj = null;
- JSONObject dataJsonObj = new JSONObject(strJson);
- Log.d(LOG_TAG, strJson);
- Log.d(LOG_TAG, "JSON " + dataJsonObj);
- } catch (JSONException e) {
- e.printStackTrace();
- } }
- org.json.JSONException: End of input at character 0 of
- java.io.FileNotFoundException: http://api.twitch.tv/kraken/streams/ajfafaasf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement