本帖最后由 huoyunfenlan 于 2012-03-31 02:48:59 编辑

解决方案 »

  1.   

    10.0.2.2是什么地址啊?如果你走的是gprs,就需要公网的IP
      

  2.   

    android emulator连接本机服务器时,用localhost会被默认为emulator的服务器,必须使用10.0.2.2,否则会出现connection to http://localhost:8080 refused XmlRpcException
      

  3.   

    为什么不能直接访问?我看很多android xml rpc例子都是用的10.0.2.2:8080进行访问的,包括android-xmlrpc这个包的范例Test.java里面也是写的http://10.0.2.2:8888。
    请不吝赐教,谢谢!
      

  4.   

    总算自己解决了,解决方法如下:
    manifest.xml里面需要添加网络访问许可。<uses-permission android:name="android.permission.INTERNET"></uses-permission>
    另外,如果还有android.os.NetworkOnmainThreadException的问题,是跟版本有关。
    添加以下红色代码即可解决:public void onCreate(Bundle savedInstanceState) {
        
         StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()     
            .detectDiskReads()     
            .detectDiskWrites()     
            .detectNetwork()   // or .detectAll() for all detectable problems     
            .penaltyLog()     
            .build());     
         StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()     
            .detectLeakedSqlLiteObjects()     
            .detectLeakedClosableObjects()     
            .penaltyLog()     
            .penaltyDeath()     
            .build());

     
            super.onCreate(savedInstanceState);