new BackTask().execute("URL");
}
private class BackTask extends AsyncTask<String, Integer, String> {
@Override
protected void onPreExecute() {
}
protected String doInBackground(String... address) {
String output = "";
try {
java.net.URL url = new java.net.URL(address[0]);
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(url.openStream()));
String line;
while ((line = in.readLine()) != null) {
output += line;
}
in.close();
} catch (java.net.MalformedURLException e) {
output = e.getMessage();
} catch (java.io.IOException e) {
output = e.getMessage();
} catch (Exception e) {
output = e.toString();
}
return output;
}
protected void onProgressUpdate(Integer... values) {
}
protected void onPostExecute(String s){
textview1.setText(s);
}
}
{
Komentar