Android 连接 就是 Java 连接,一般用Socket,网上关于Java网络编程的例子很多,给你几个连接,可以看看。http://blog.csdn.net/hbcui1984/archive/2006/12/12/1439880.aspx关于Java IO流的
http://blog.csdn.net/xiaoenxiaohui8/archive/2009/05/04/4145866.aspx
http://blog.csdn.net/liu251/archive/2009/02/03/3860578.aspx

解决方案 »

  1.   

    做网络连接,肯定牵涉到端口,很显然要用到Socket和流,原来我做的一个聊天的窗口就用到了这些
      

  2.   

    顶一下!~想要http和webservice通信的代码~谢谢!
      

  3.   

    http可以用httpclient和URLConnection,也是Java的东西,查查就很多咯
      

  4.   

    给你一段通过http连接web的代码
    HttpClient httpClient = new DefaultHttpClient();
    // HttpContext localContent = new BasicHttpContext();
    HttpGet httpGet = new HttpGet(GOOGLE_API_URL + city);

    try {
    // HttpResponse response = httpClient.execute(httpGet, localContent);
    HttpResponse response = httpClient.execute(httpGet);
    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
    Log.e(TAG, "Failed. status code is not ok.");
    httpGet.abort();
    } else {
    // Get weather information successful
    // Reset charset for Chinese
    HttpEntity httpEntity = response.getEntity();
    String string = EntityUtils.toString(httpEntity, "utf-8").trim();
    InputStream is = new ByteArrayInputStream(string.getBytes());
    return parseWeather(is);
    }

    } catch (Exception e) {
    Log.e(TAG, "Failed to get weather information.", e);
    e.printStackTrace();
    } finally {
    // disconnect network
    httpClient.getConnectionManager().shutdown();
    }
      

  5.   


                // CMWAP连接方式
                if (connection.Type == 1)
                {
                    URL url = new URL(urlString);
                    httpUrlConnection = (HttpURLConnection) url.openConnection();
                    httpUrlConnection.setRequestProperty("X-Online-Host", task.url
                        );
                    httpUrlConnection.setRequestProperty("Accept", "*/*");
                }
                // CMNET连接方式
                else
                {                String newUrl = geturl();
                    URL url = new URL(newUrl);                httpUrlConnection = (HttpURLConnection) url.openConnection();            }
                httpUrlConnection.setRequestProperty("Accept", "*/*");
                httpUrlConnection.setRequestProperty("Pragma", "No-cache");
                httpUrlConnection.setRequestProperty("Cache-Control", "no-cache");
                httpUrlConnection.setRequestProperty("connection", "keep-alive");
                httpUrlConnection.setRequestProperty("accept-charset", "utf-8");            httpUrlConnection.setRequestProperty("User-Agent", "Mozilla/5.0");            httpUrlConnection.setRequestProperty("x-up-calling-line-id",
                    "13800000");
                        // POST方式
                if (conntion.data != null)
                {
                    httpUrlConnection.setDoInput(true);
                    httpUrlConnection.setDoOutput(true);
                    httpUrlConnection.setRequestMethod("POST");
                    httpUrlConnection.setUseCaches(false);
                    httpUrlConnection.setInstanceFollowRedirects(false);
                    httpUrlConnection.setRequestProperty("Content-Type",
                        "application/xml");
                    PrintWriter out = new PrintWriter(httpUrlConnection
                        .getOutputStream());
                    out.print(connection.data);
                    out.flush();
                    out.close();            }
                // GET方式
                else
                {
                    httpUrlConnection.setRequestMethod("GET");
                }            // 获取HTTP请求返回码
                int code = httpUrlConnection.getResponseCode();
                //            time.cancel();            if (code != HttpURLConnection.HTTP_OK)
                {
                    return null;
                }
      

  6.   

    恩,知道了,谢谢大家,以前写j2me 用的httpconnection  这里就不知道用什么了。