How to make Web Source code viewer app in Sketchware
Web source code viewer app in sketchware.
First you have to make a app with edittext, button, linear, scollview and a textview for showing results.
Then create a more block extra which create a AsyncTask with name BackTask.
Then add the following code:-
}
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){
textview2.setText(s); }
Notice:- here textview2 is given for showing results you can change according to view.
And then create a moreblock with name ShowSourceCode with textview text
And then add the following code:-
new BackTask().execute(_text.getText().toString());
In OnCreate add a webview load url block for internet permission
And in button one add the ShowSourceCode moreblock with editext.
After that run the project and enter url after 1 - 5 seconds it will show sourcecode of the website.






Comments
Post a Comment