android 使用http服务打开网页·怎么实现啊?

解决方案 »

  1.   

    去看看 URLConnetion HttpURLConnetion  的用法吧
      

  2.   


    能够得到网页打开过程的数据(至少是HTTP包头)。这个不可以啊···
    而且我的时没有界面的···
      

  3.   

    你能锁具体点吗?
    能够得到网页打开过程的数据(至少是HTTP包头)。这个不可以啊···
    而且我的时没有界面的···
      

  4.   

    网上很多的 HttpRrlConnection链接HTTP服务器
    http://www.cnblogs.com/guodongli/archive/2011/04/05/2005930.html
      

  5.   


    我连接上···既要得到网页打开过程的数据(至少是HTTP包头)。
      还要打开网页····怎么实现啊···大哥····
      

  6.   

    httpUrlConnection 链接http服务器器,链接完以后httpUrlConnection .getHeaderFields()里面有所有报头,至于打开网页,可以读取body体所有内容,然后拼接成字符串,再通过系统自带的webview去渲染,具体点就是webview.loadData().(当然如果你想自己先做,接去把body体内容取得,然后自己去解析html文件,呵呵)
      

  7.   

    在你取得头信息以后,再通过发送Intent调用系统浏览器打开网页呗
      

  8.   


    PackageManager packageMgr = getPackageManager(); intent = packageMgr.getLaunchIntentForPack("com.android.browser");
    intent.setAction(Intent.ACTION_VIEW);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse(url.toString()));
    startActivity(intent);

    这个意图时打开网页···
    之前时这样写的··但是打开就看不到东西···
    流量检测没有反应····
      

  9.   

    WebView webview = new WebView (this);
    setContentView(webview );
    try { 
    //InputStream fin = getAssets().open("3.txt");
    InputStream fin = new FileInputStream("/sdcard/eAirflux/3.txt");
    byte[] buffer = new byte[fin.available()];
    fin.read(buffer);
    fin.close();
    webview.loadData(new String(buffer), "text/html", "GBK");
    }
    catch (IOException e) { 
    e.printStackTrace(); 
    }
      

  10.   

    public  int ping() {
    String system = (String) (System.getProperty("os.name")).toLowerCase();
    Log.d("eairflux", "system----------------" + system);
    String  pingCommand = "";
    if (system.indexOf("win") != -1) {
    pingCommand = "ping " + host + " -l " + leng + " -c "
    + count +  " -i " + interval_data + " -w "
    + wait;//" -t " + ping.getReExeTimes() + " -n "+ ping.getReExeTimes() +

    } else if (system.indexOf("linux") != -1) {
    pingCommand = "ping " + host + " -l " + leng + " -c "
    + count +  " -i " + interval_data + " -w "
    + wait;
    } else {
    pingCommand = "ping " + host + " -l " + leng + " -c "
    + count +  " -i " + interval_data + " -w "
    + wait;

    }
    Log.d("eairflux", "pingCommand--------------------" + pingCommand);
    int minTime = Integer.MAX_VALUE, curTime;
    try {
    Process process; process = Runtime.getRuntime().exec("ping " + host);
    Log.d("eairflux", "process--------------------" + process);
    BufferedReader in = new BufferedReader(new InputStreamReader(
    process.getInputStream()));
    String line="";
    int count = 10, index;
    // 最多只读10行
    Log.d("eairflux", "line--------------------" + line);
    if(in.readLine()==null||in.readLine().equals(""))
    {
    return 0;
    }
    while (!((line = in.readLine()).equals("")) && count-- != 0) {
    Log.d("eairflux", "in.readLine()--------------------" + in.readLine());
    line = line.toLowerCase();
    Log.d("eairflux", "line.toLowerCase()--------------------" + line.toLowerCase());
    if ((index = line.indexOf("time")) != -1) {
    Log.d("eairflux", "buf--------------------" + line.getBytes());

    byte[] buf = line.getBytes();
    int start = 0, end = buf.length, i, j;
    for (i = index + 4; i < buf.length; i++) {
    if (Character.isDigit((char) buf[i])) {
    start = i;
    Log.d("eairflux", "start------------" + start);
    break;
    }
    }
    if (i == buf.length){
    Log.d("eairflux", "buf.length------------" + buf.length);
    continue;
    }
    for (j = start; j < buf.length; j++) {
    if (Character.isLetter((char) buf[j])) {
    end = j;
    Log.d("eairflux", "end------------" + end);
    break;
    }
    }
    curTime = Integer.parseInt(new String(buf, start, end
    - start));
    if (curTime < minTime) {
    Log.d("eairflux", "minTime------------" + minTime);
    Log.d("eairflux", "curTime------------" + curTime);

    minTime = curTime;
    }
    }
    }
    } catch (NumberFormatException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return minTime;
    }