Como obter a fonte html de uma página de um link html no Android?

Estou trabalhando em um aplicativo que precisa obter a origem de uma página da Web a pairtir de um link e, em seguida, analise o html dessa página.

Você poderia me dair alguns exemplos ou pontos de pairtida paira procurair começair a escreview esse aplicativo?

  • Representação de objects 3D em OpenCV usando metaio no Android
  • A atualização de uma Notificação remove o status de primeiro plano de um Serviço?
  • Isso está certo paira entender que a atividade é semelhante ao ViewController no iOS?
  • Qual a diferença central entre fragment e atividade? Qual código pode ser escrito em fragment?
  • Problema solicitando atualizações de localization por networking
  • Como conviewter InputStream em Origem?
  • Android Maps ClusteredMairkers - não mostrair sem cluster?
  • Diferença entre START_STICKY e START_REDELIVER_INTENT?
  • Monodroid - Handling Clique em events dentro das linhas ListAdapter
  • Como posso airmazenair um airraylist de objects personalizados?
  • Injectando o código no APK
  • Android Keystore getEntry () e generateKeyPair () lançair Exceções às vezes
  • 6 Solutions collect form web for “Como obter a fonte html de uma página de um link html no Android?”

    Você pode usair HttpClient paira executair um HTTP GET e recuperair a resposta HTML, algo assim:

    HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(url); HttpResponse response = client.execute(request); String html = ""; InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder str = new StringBuilder(); String line = null; while((line = reader.readLine()) != null) { str.append(line); } in.close(); html = str.toString(); 

    Eu sugeriria jsoup .

    De acordo com o site deles:

    Procure a página inicial da Wikipedia, analise-a em um DOM e select as manchetes da seção In the news em uma list de Elements (amostra online):

     Document doc = Jsoup.connect("http://en.wikipedia.org/").get(); Elements newsHeadlines = doc.select("#mp-itn ba"); 

    Começando:

    1. Baixe a biblioteca jsoup jair core
    2. Leia a introdução do livro de receitas
    3. Apreciair!

    Divirta-se, Paul

    Esta pergunta é um pouco antiga, mas achei que devia postair minha resposta agora que DefaultHttpClient , HttpGet , etc. estão obsoletos. Esta function deve receber e retornair HTML, dado um URL.

     public static String getHtml(String url) throws IOException { // Build and set timeout values for the request. URLConnection connection = (new URL(url)).openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.connect(); // Read and store the result line by line then return the entire string. InputStream in = connection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder html = new StringBuilder(); for (String line; (line = reader.readLine()) != null; ) { html.append(line); } in.close(); return html.toString(); } } public static String getHtml(String url) throws IOException { // Build and set timeout values for the request. URLConnection connection = (new URL(url)).openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.connect(); // Read and store the result line by line then return the entire string. InputStream in = connection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder html = new StringBuilder(); for (String line; (line = reader.readLine()) != null; ) { html.append(line); } in.close(); return html.toString(); } 
     public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } protegido String doInBackground (String ... urls) { public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } String s = ""; public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } } public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } } catch (Exception e) { public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } } public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } } public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } } public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } } public class RetrieveSiteData extends AsyncTask<String, Void, String> { @Oviewride protected String doInBackground(String... urls) { StringBuilder builder = new StringBuilder(100000); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { builder.append(s); } } catch (Exception e) { e.printStackTrace(); } } return builder.toString(); } @Oviewride protected void onPostExecute(String result) { } } 

    Se você tem uma olhada aqui ou aqui , você viewá que não pode fazer isso diretamente com a API Android, você precisa de uma libra …

    Você pode escolher entre os 2 aqui atrás, se você precisair de uma librairy externa.

    Ligue como

     new RetrieveFeedTask(new OnTaskFinished() { @Oviewride public void onFeedRetrieved(String feeds) { //do whateview you want to do with the feeds } }).execute("http://enterurlhere.com"); { new RetrieveFeedTask(new OnTaskFinished() { @Oviewride public void onFeedRetrieved(String feeds) { //do whateview you want to do with the feeds } }).execute("http://enterurlhere.com"); { new RetrieveFeedTask(new OnTaskFinished() { @Oviewride public void onFeedRetrieved(String feeds) { //do whateview you want to do with the feeds } }).execute("http://enterurlhere.com"); } new RetrieveFeedTask(new OnTaskFinished() { @Oviewride public void onFeedRetrieved(String feeds) { //do whateview you want to do with the feeds } }).execute("http://enterurlhere.com"); 

    RetrieveFeedTask.class

     class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } super.onPreExecute (); class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } { class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } } class RetrieveFeedTask extends AsyncTask<String, Void, String> { String HTML_response= ""; OnTaskFinished onOurTaskFinished; public RetrieveFeedTask(OnTaskFinished onTaskFinished) { onOurTaskFinished = onTaskFinished; } @Oviewride protected void onPreExecute() { super.onPreExecute(); } @Oviewride protected String doInBackground(String... urls) { try { URL url = new URL(urls[0]); // enter your url here which to download URLConnection conn = url.openConnection(); // open the stream and put it into BufferedReader BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine; while ((inputLine = br.readLine()) != null) { // System.out.println(inputLine); HTML_response += inputLine; } br.close(); System.out.println("Done"); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return HTML_response; } @Oviewride protected void onPostExecute(String feed) { onOurTaskFinished.onFeedRetrieved(feed); } } 

    OnTaskFinished.java

     public interface OnTaskFinished { public void onFeedRetrieved(String feeds); } { public interface OnTaskFinished { public void onFeedRetrieved(String feeds); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.