Tools - AsynTask Source URL

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

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

A Flash Light App in Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Firebase Login/Register with email verification

Codes for modifying Action Bar in Sketchware

Code for implementing Notifications in Sketchware