显示服务器上发布的新消息的 Android 应用程序
我正在寻找可以帮助我制定以下应用程序工作流程的阅读资源或示例应用程序:
客户端应用程序建立与我们的服务器的连接
客户端应用程序定期扫描更新
- 发布了新消息,则新消息将显示在小部件中。
我目前有两个顾虑:
我想确保监控服务不会消耗大量电池。
建立连接以检索数据的最安全、最简单的方法是什么? ....那里有很多建议...我需要知道我应该研究什么方法而不是其他方法。目前,所有选项都已摆在桌面上,因为我尚未配置我们的服务器。
I am looking for reading resources or sample applications that can help me hammer out the following application workflow:
The client application establishes a connection to our server
The client application scans for updates on a regular interval
If an administrator has posted a new message, the new message is displayed in a widget.
I currently have 2 concerns:
I want to ensure that the monitoring service is not a major battery drain.
What is the most secure and simple method to establish the connection to retrieve data?
....There are a lot of suggestions out there... I need to know what method I should be researching over all others. Currently, all options are on the table because I have yet configure our server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有很多问题,我会尽力给出一个简洁的答案。
对于基础设施,我将使用 HTTP REST 调用来检索表示消息的 JSON 数据。 这里是一个不错的有关为 Android 编写 HTTP REST 客户端的链接,网上还有很多其他内容。
为了安全起见,我肯定会从 SSL 开始,但如果您需要对请求进行身份验证,我还会查看 OAuth 以保护您的远程 API。
There are a lot of questions here, I'll try to give a succinct answer.
For the infrastructure I would go with HTTP REST calls to retrieve JSON data reprsenting your messages. Here is a decent link about writing an HTTP REST client for android, there are many others online.
For security, I would definitely start with SSL, but if you need to authenticate the requests I would also look at OAuth to secure you remote API.
至于 A,您是否考虑过使用 C2DM(又名“push”)来触发更新?这样一来,客户端带宽就不会超出 Market/GMail/Talk 连接所使用的带宽。不过,如果您需要支持低于 2.2 的 Android 版本,目前还不是一个真正的选择。
除此之外,还有一些在小部件进行投票时成为好公民的好例子; Jeff Sharkey 的 android-sky 可能是最古老、最好、最权威的。
对于 B,除非我误解了您的需求,否则很难击败 HTTPS;通过普通 HTTP 或任何较低级别的东西来滚动你自己的“安全”传输只会带来灾难。
As far as A, Have you considered using C2DM (aka "push") to trigger the updates? Then there's no client bandwidth beyond what is being used anyways for the Market/GMail/Talk connection. If you need to support Android versions below 2.2 it's not really an option at the moment, though.
Otherwise there's a few good examples of being a good citizen when polling from a widget; Jeff Sharkey's android-sky is probably the oldest, best, and most authoritative.
For B, unless I'm misunderstanding your need it's pretty hard to beat HTTPS; rolling your own "secure" transport over vanilla HTTP or anything lower-level is just asking for a disaster.