连接到与Android的网络服务器 [英] Connecting to a webserver with android

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

问题描述

我要连接到从Android的一个网络服务器,我要访问一个Web服务和Web服务器的网页。任何人可以帮助我吗?请给循序渐进的过程有些code段,因为我是新来的Andr​​oid和我不知道在连接到一个网络服务器的任何事情。

I have to connect to a webserver from android and I have to access a webservice and a webpage from the webserver. Can anybody help me? Please give step by step process with some code snippets because I am new to android and I don't know anything in connecting to a webserver.

推荐答案

您可以使用的 的HttpClient

You can use an HttpClient:

HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(uri);
HttpResponse httpResponse = httpClient.execute(httpGet);
BufferedReader reader = new BufferedReader(
    new InputStreamReader(httpResponse.getEntity().getContent()));
// user reader to read & parse response 
reader.close();

显然解析响应取决于格式(如 SOAP JSON ,等等。)

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

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