I am writing a program on androyd I can not understand why my code is not displayed in the "textView"
class BackgroundTask extends AsyncTask<String, Void, String>{ String json_url; @Override protected void onPreExecute() { json_url ="myurl"; } @Override protected String doInBackground(String... params) { try { URL url = new URL(json_url); try { HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); InputStream inputStream = httpURLConnection.getInputStream(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder stringBuilder = new StringBuilder(); while((JSON_STRING = bufferedReader.readLine())!=null) { stringBuilder.append(JSON_STRING+"\n"); } bufferedReader.close(); inputStream.close(); httpURLConnection.disconnect(); return stringBuilder.toString().trim(); } catch (IOException e) { e.printStackTrace(); } } catch (MalformedURLException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String result) { TextView textView = (TextView) findViewById(R.id.textView2); textView.setText(result); } } my text result should display my "result" after clicking a button. My text is updated, but remains empty. The desired message is not displayed I can not find the error.
result? - tim_taller