1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| package com.load.page_html;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class Main extends Activity {
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
try{
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet();
URI uri = new URI("http://www.thinkdroid.eu");
httpGet.setURI(uri);
HttpResponse httpResponse = httpClient.execute(httpGet);
InputStream inputStream = httpResponse.getEntity().getContent();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String ligneCodeHTML = bufferedReader.readLine();
StringBuffer stringBuffer = new StringBuffer("");
while (ligneCodeHTML != null)
{
stringBuffer.append(ligneCodeHTML + "\n");
ligneCodeHTML = bufferedReader.readLine();
}
WebView webView = new WebView(this);
webView.loadDataWithBaseURL("fake:", ligneCodeHTML, "text/html", "utf-8", "");
}
catch (Exception e) {
e.printStackTrace();
}
}
} |
Partager