android 使用http服务打开网页·怎么实现啊?
解决方案 »
- 如何在应用程序里用手机自带的音量键控制媒体音量?
- 打开关闭背景数据和数据漫游
- 请问如何清空android里gridview里的数据
- 明天老师检查,我还没有解决这个空指针异常,急死我啦!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 从用android编写的Linphone当中抽取出最简单的通话功能
- 跪求:控件的滑动隐藏
- 新手求助!如何提取出自己想要的JSON格式化数据
- android xml布局文件中控件属性的官方文档在哪看
- 请教Email自动发送异常
- android layout 的背景覆盖了子控件
- android 用广播启动服务,在服务里启动activity,执行停止时第一次可以停止,后面不可以停。郁闷啊·····大侠帮帮忙
- android:background 能否写在style.xml里?
能够得到网页打开过程的数据(至少是HTTP包头)。这个不可以啊···
而且我的时没有界面的···
能够得到网页打开过程的数据(至少是HTTP包头)。这个不可以啊···
而且我的时没有界面的···
http://www.cnblogs.com/guodongli/archive/2011/04/05/2005930.html
我连接上···既要得到网页打开过程的数据(至少是HTTP包头)。
还要打开网页····怎么实现啊···大哥····
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);
、
这个意图时打开网页···
之前时这样写的··但是打开就看不到东西···
流量检测没有反应····
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();
}
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;
}