Android的REST客户端

编程入门 行业动态 更新时间:2024-10-08 22:21:01
本文介绍了Android的REST客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我发现这么多的样本请求REST API,但所有一起是混乱的,可有人请解释我的方式来使用HTTP请求。​​

I found so many samples for requesting a REST API, but all together are confusing, can some one please explain me a way to use http requests.

我的要求是,我想通过提供用户名,PWD和一键从一个REST API的数据。

My Requirement is, I want to get data from a REST API by providing username, pwd and a key.

我已经使用了,

HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("REST API url"); post.setHeader("Content-type", "application/json"); JSONObject obj = new JSONObject(); obj.put("username", "un"); obj.put("pwd", "password"); obj.put("key","123456"); post.setEntity(new StringEntity(obj.toString(), "UTF-8")); HttpResponse response = client.execute(post);

但响应总是空当与浏览器的工具,通过发布相同data.Is有些事情错了我的方法测试了这些工作的罚款?请给我建议的正确方法。谢谢

But the response is always null and these working fine when tested with browser tool by posting the same data.Is some thing wrong with my approach? please suggest me the correct way. Thank you

推荐答案

(1)谷歌I / o视频会议发展的REST客户端

(2)在Android开发者博客搜索

(2) search in android developer blog

(3) github/darko1002001/android-rest-client

后请尽量发布您的问题, 我可以从我的REST客户端共享code段开发了基于(1)及(2)

Please try after that post your question, I can share code snippet from my rest client developed based on (1) & (2)

不要使用云到设备消息,而是使用了最新的云计算方法与andrid应用程序的开发。

Do not use Cloud to Device Messaging, instead use the latest cloud approach with andrid application development.

有新的库被称为排球,它看起来比AsyncTask的更好。它应该是在开发REST风格的客户端十分有用。

There is new library called Volley, which looks better than AsyncTask. It should be useful in developing RESTful clients.

更多推荐

Android的REST客户端

本文发布于:2023-11-13 02:41:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583197.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   Android   REST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!