无法与互联网连接 [英] Unable to connect with internet

查看:116
本文介绍了无法与互联网连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我试图用互联网这个code连接:

Hi I'm trying to connect with internet with this code:

  DefaultHttpClient httpclient = new DefaultHttpClient();  
  HttpPost httppost = new HttpPost("http://192.168.0.100/webnet/xyz.php");
  String result = null;
  InputStream is = null;
  StringBuilder sb = null;
  HttpResponse response = httpclient.execute(httppost);

我注册的互联网上的权限清单文件

I registered Internet permission on manifest file

我得到这个错误:

System.err的android.os.StrictMode $ AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)

System.err android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)

我测试这个程序与API级别8

I tests this app with API level 8

推荐答案

执行code这个块之前试试这个。 5工作在一些情况下

Try this before executing this block of code. may works in some cases:

try {
                Class strictModeClass=Class.forName("android.os.StrictMode");
                Class strictModeThreadPolicyClass=Class.forName("android.os.StrictMode$ThreadPolicy");
                Object laxPolicy = strictModeThreadPolicyClass.getField("LAX").get(null);
                Method method_setThreadPolicy = strictModeClass.getMethod("setThreadPolicy",strictModeThreadPolicyClass );
                method_setThreadPolicy.invoke(null,laxPolicy);
            }
        catch (Exception e) {

            }

和问问题之前,这里试试这个:google.com#接受与kevinDTimm

And Try this before asking questions here: "google.com" # accepts with kevinDTimm

这篇关于无法与互联网连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆