用httpGet或post貌似只能传递参数,。,如果我想传递一个对象如User或图片  怎么传递是不是要先转化为byte啊。。怎么转化呢。。

解决方案 »

  1.   

    socket,最简单。其他的都是在这个上面弄起来的,图片转换,如果你要通过http这样的东东,就要先转字符串了,建议用BASE64编解码,但是太大就完蛋了
      

  2.   

    谢啦 我用socket的编程如下 又出现新的错误:
    客户端:
    public class sendSocket {
     public  sendSocket(Object obj,Context c)   throws   Exception   { 
             Socket   s   =   new   Socket( "113.55.35.103 ",   14567);
             ObjectOutputStream   oos   =   new   ObjectOutputStream(s.getOutputStream()); 
             oos.writeObject(obj); 
             oos.flush(); 
             System.out.println( "Send   finish" +
              "ed. "); 
     } 
    }
    服务器端:
    public   class   ObjectServer   { 
    //private Socket s ;
    public static Socket s1 ;
        public  static   void   main(String   arg[])   throws   Exception   { 
                int   port   =   14567; 
                ServerSocket   socket   =   new   ServerSocket(port); 
                System.out.println( "Server   is   running   on   "   +   port); 
                System.out.println( "Press   [Ctrl+C]   to   abort "); 
                while   (true)   { 
                        Socket   s   =   socket.accept(); 
                        ObjectServer.s1 = s;
                } 
                
        }     

    android虚拟机半天没反应 最后来了一个:requesttime time failed :java.net.SocketException:
    Address family not supported by protocol
      

  3.   

    FileEntity 传文件 StringEntity 传字符串  HttpEntity 传的是List  具体怎么操作 自己去试验下
      

  4.   

    首先,你确定服务器运行正常,ip/port没错吗?还有你手机联网了么?
    如果都正常,那你就需要看看你是否在你的manifest文件里声明允许了,<uses-permission android:name="android.permission.INTERNET" />必须要这样才行,你试试看