简体   繁体   English

在android上执行Http请求

[英]performing a Http request on android

Could someone provide the basic code to use if I want to perform a http request on android to the address "address" with the string "message" ? 如果我想在Android上使用字符串“ message”对地址“ address”执行http请求,有人可以提供要使用的基本代码吗? Also I'd like to check the server response and perform some actions if the right conditions meet , but I ' m unsure of how and when the server send back the response . 另外,我想检查服务器的响应并在适当的条件满足时执行一些操作,但是我不确定服务器如何以及何时发送回响应。 My guess is that the response is gotten in a blocking function, or in an asynchronous function . 我的猜测是,响应是通过阻塞函数或异步函数获得的。 Could you provide code or information on this as well ? 您是否也可以提供代码或信息? Great thanks from a novice with too much on his head ! 非常感谢新手,他头上的东西太多了!

The above refers to a more complex asynchronous way, but if you want something simple and blocking, that is basic core java - http://developer.android.com/reference/java/net/URL.html 上面提到的是一种更复杂的异步方式,但是如果您想要一些简单且阻塞的东西,那就是Java的基本核心-http: //developer.android.com/reference/java/net/URL.html

see URL.getContent(), etc. 参见URL.getContent()等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM