Android上实现Push

详细请点击:http://www.verydemo.com/demo_c131_i26919.html

这些天一直在琢磨如何在android device上实现一套Push功能,也google很多资料,看似无外乎以下三个方案(以下转载):

 

  • Poll? The name obviously tells you that it’s really not even push. The idea here is to periodically poll the server for new messages from a background local or remote service. The more often you poll the closer you get to the real-time push.
: easy to implement. no cost solution
: Obviously, you will never be actually real-time. If you polling interval is 30 min, you can get a message that is 29 minutes and 59 seconds late. Moreover, polling more often than every 15-30 min will kill your battery pretty quickly: https://labs.ericsson.com/apis/mobile-java-push/blog/save-device-battery-mobile-java-push
  • SMS Android allows you to intercept SMS messages. Your server sends a specially encoded SMS to your phone, whenever there is something new. Your app intercepts all messages, looks for the ones from the server, then pops up a notification.
: easy to implement. Fully real-time updates. Known drop-in solutions exist such as one provided by Ericsson  Labs: https://labs.ericsson.com/apis/mobile-java-push/
: Can be costly to you and the user. There are only a few services that allow you send around free SMS and even those are often limited to North America. If you want to have a reliable SMS-based service that is available worldwide, you will likely need to pay. Similar goes for the users. Not everyone has an SMS plan and you don’t want your users getting charged by 3rd party for using your app.
  • Persistent TCP/IP The phone initiates a long-lived mostly idle TCP/IP connection with the server and maintains it by occasionally sending keepalive messages. Whenever there is something new on the server, it sends a messages to the phone over the TCP connection.
: Fully real-time updates.

 

 这里是两篇我觉得说得很好的网址:

http://tokudu.com/2010/how-to-implement-push-notifications-for-android/ 

http://blog.csdn.net/joshua_yu/article/details/6563587 

 

当然,我的第一选择也是尝试C2DM,在注册完C2DM服务的账号后,google发的“AC2DM invitation”邮件里有提到仍处在试验中,加上我们要实现的产品需要一个稳定环境,所以尝试至此,也就中途放弃了,有兴趣的可以继续:http://code.google.com/intl/zh-CN/android/c2dm/#intro


之后,我开始尝试使用openfire+smack来自己搭建一个Push platform,用openfire作为Push service,然后借用anroidpn开源工程代码(做了一定的修改),能够做到从Server Push信息到android client。对于这套方案,我并没有做并发测试(这里有提到:http://wenku.baidu.com/view/85cfcd5f312b3169a451a41f.html)以及电量消耗测试,因此只能说,这个可行,也易于实现

 

最终我们要选择哪种方式,现在还没有明确的答案,不过也不远了。。 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值