Posts

Showing posts with the label Read online text page in android

Display url source code or online text file in android TextView

Image
To display an online text file or source code of any web url, in a TextView, we have to do following: Create a URL object from the String representation. Use openStream() method to open a connection to this URL and and get the InputStream for reading from that connection. Create a new BufferedReader , using a new InputStreamReader with the URL input stream. Read the text, using readLine() method of BufferedReader. But this cannot be done directly in an android project because android apps do not allow networking operation on its main UI thread. Therefore we need to use AsyncTask class, which allows us to perform background operations and publish results on the UI thread. To create such an online text file reader app in sketchware, follow the steps given below: 1. Create a new project in Sketchware. In VIEW area add a LinearV inside a ScrollV. In this add an EditText edittext1  (for writing URL), a Button button1 , and a TextView textview1  (for...