A
andele78
Neues Mitglied
- 0
Hi Zusammen, Versuche über PHP/MySQL eine ROW in eine TextView einzulesen ,komme zu keinen ergebniss.
Code:
class BackgroundTask extends AsyncTask<Void,Void,String>
{
String json_url;
@Override
protected void onPreExecute() {
json_url = VTCConfig.GETVTC1;
}
@Override
protected String doInBackground(Void... voids) {
try {
URL url = new URL(json_url);
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 (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String result) {
TextView textView = (TextView)findViewById(R.id.vtc30_1_txt);
textView.setText(result);
}
}