在android上执行Http请求

问题描述:

如果我想在android上使用字符串“message”对地址“address”执行http请求,有人可以提供基本代码吗?另外我想检查服务器响应,并在正确的条件满足时执行一些操作,但我不确定服务器如何以及何时发送响应。我的猜测是,响应是在阻塞函数或异步函数中获得的。你能提供这方面的代码或信息吗? 非常感谢一位新手,他的头太多了!在android上执行Http请求

+0

你可能只是想做一个搜索。这个问题的答案看起来不错:http://stackoverflow.com/questions/874227/android-project-using-httpclient-http-client-apache-post-get-method – 2010-04-13 16:33:11

+0

你是对的,但指出一个坏问题。 – Janusz 2010-04-13 16:37:32

+0

http://stackoverflow.com/questions/2022170/how-to-execute-web-request-in-its-own-thread – Janusz 2010-04-13 16:40:33

以上指的是一个更复杂的异步方式,但是如果你想要的东西简单而阻塞,这是基本的Java核心 - http://developer.android.com/reference/java/net/URL.html

看到URL.getContent()等