简体   繁体   English

如何设置HTTP调用和响应?

[英]How do I setup an HTTP call and response?

I'm new to programming Android and looking at the example on how to connect to the cloud ( http://developer.android.com/training/basics/network-ops/connecting.html ). 我是不熟悉Android编程的人,并且正在研究有关如何连接到云的示例( http://developer.android.com/training/basics/network-ops/connecting.html )。 I want to send a POST request to a server and receive a response. 我想向服务器发送POST请求并接收响应。

Where do I put the "public class HTTPExampleActivity..." code from the example? 我将示例中的“公共类HTTPExampleActivity ...”代码放在哪里? Does that go in my main activity as a second class or do I create a different java file for that class? 这是否作为第二堂课进入了我的主要活动,还是为该堂课创建了一个不同的Java文件? If the latter, how do I create that document in Eclipse? 如果是后者,如何在Eclipse中创建该文档? is it a "new activity" or something else? 是“新活动”还是其他?

It depends on your choice. 这取决于您的选择。 It could be within your Activity or could be within a different plain class. 它可以在您的活动中,也可以在其他简单类中。

Have a look here : 在这里看看:

http://www.androidhive.info/2011/10/android-making-http-requests/ http://www.androidhive.info/2011/10/android-making-http-requests/

http://mobiledevtuts.com/android/android-http-with-asynctask-example/ http://mobiledevtuts.com/android/android-http-with-asynctask-example/

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

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