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.example.test100;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.widget.TextView;
public class Test100 extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test100);
TextView texte = null;
texte = (TextView)findViewById(R.id.texte);
String htmlCode = "";
String LOG_TAG ="";
try {
URL url = new URL("http://www.texto-sms-gratuit.com/android/1.html");
texte.setText("OK 1");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
texte.setText("OK 2");
String inputLine;
while ((inputLine = in.readLine()) != null)
htmlCode += inputLine;
in.close();
} catch (Exception e) {
texte.setText("Erreur: "+e.getMessage());
}
}
} |
Partager