http://bigcat.easymorse.com/?p=1210

参考http://code.google.com/intl/zh-CN/android/c2dm/index.html#intro android2.2以上支持,支持第三方应用程序的push。实现令人心动的消息push,GMail就是这么实现的,收信的速度比网页还快。 Components: 1,移动设备:必须运行android,并且安装Market,至少有一个登录的google账号。(Google坑爹啊) 2,自己的服务器:自己的服务器 3,C2DM服务器:google的服务器 授权机制: 1,Sender ID:一个google账号,用于标示开发者的身份,比如my-app@google.com 2,Application ID:Manifest.xml里面的pacakage name。用于标示应用程序 3,Registration ID:当应用程序向C2DM服务器注册时,C2DM服务器会返回这个ID,当应用程序获得这个ID之后,应该告诉自己的服务器,自己的服务器把这个ID存在数据库里面,用于告诉C2DM服务器标示客户端。 4,Google User Account:要使用C2DM服务,必须有一个google账号,再骂一次,坑爹啊GG。 5,Sender Auth Token:自己的服务器与C2DM服务器通信的认证。 应用程序发送Intent,com.google.android.c2dm.intent.REGISTER,附上自己的SenderID和AppId,就可以向C2DM服务器进行注册,注册成功之后,可以收到REGISTRATION Intent,获得Registration ID,这个Registration ID是会被C2DM改变的,所以这个REGISTRATION Intent可能会收到多次,要记得存储和发送给自己的服务器。 Here is the sequence of events that occurs when the application server sends a message: 1,The application server sends a message to C2DM servers. 2,Google enqueues and stores the message in case the device is inactive. 3,When the device is online, Google sends the message to the device. 4,On the device, the system broadcasts the message to the specified application via Intent broadcast with proper permissions, so that only the targeted application gets the message. This wakes the application up. 5,The application does not need to be running beforehand to receive the message.The application processes the message. If the application is doing non-trivial processing, you may want to grab a wake lock and do any processing in a Service. An application can unregister C2DM if it no longer wants to receive messages. This is the sequence of events that occurs when an Android application running on a mobile device receives a message: 1,The system receives the incoming message and extracts the raw key/value pairs from the message payload. 2,The system passes the key/value pairs to the targeted Android application in a com.google.android.c2dm.intent.RECEIVE Intent as a set of extras. 3,The Android application extracts the raw data from the RECEIVE Intent by key and processes the data.

更多相关文章

  1. Android上传图片到服务器,android-async-http上传图片到服务器
  2. Android(安卓)混合了 JSON 的 Android(安卓)应用程序
  3. Android开发必备的免费资源和工具
  4. Android性能优化——合理进行内存管理
  5. 常用Android应用程序中的Intent动作
  6. Android系统架构
  7. Android从远程服务器下载文件到本地sd卡中
  8. Activity 属性设置参数说明
  9. android应用程序跳转到系统的各个设置页面

随机推荐

  1. 图标使用、盒模型、box-sizing、百分比布
  2. Visual Studio Code如何切换为简体中文
  3. html5表格实战(课程表)
  4. 表单案例和css模块化与选择器
  5. html字体图标及盒模型练习
  6. php学习第四天
  7. HTML注册表单控件实例、CSS模块化理解与C
  8. 字体图标,布局与盒模型
  9. 酱茄OW,专为企业开发的官网小程序
  10. 测试使用的作业