使用url打开网络连接
String urlString = "http://"+et_url.getText()+"";
if(urlString.length()>0){
try {
String line = "";
URL url = new URL(urlString);
URLConnection urlConnection = url.openConnection();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
while ((line = bufferedReader.readLine())!=null){
if(line.indexOf("a href")>=0)
tv_url.setText(line);
}
bufferedReader.close();
urlConnection.getInputStream().close();
} catch (Exception e) {
e.printStackTrace();
tv_url.setText(e.toString());
}
}