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开发者指南(11) —— Optimizing Apps for Android(安卓)
  2. Android(安卓)中使用HttpUrlConnection实现get请求服务器
  3. 【MarsChen】D03_Say_Hello_to_Android
  4. Android应用程序获取ROOT权限的方法
  5. [置顶] Android应用程序中加载进度设计
  6. Android(安卓)Studio中debug和release模式默认的参数配置
  7. Android中onConfigurationChanged监视系统配置更新
  8. Android(安卓)SDK代理服务器解决国内不能更新下载问题
  9. Eclipse开发Android应用程序入门

随机推荐

  1. 谷歌Android系统版本无序发展反噬产业链
  2. Android设备重启(reboot)---Android(安卓
  3. ANDROID GreenDao 使用例子 Android(安卓
  4. linux android 下进入android shell
  5. Android之Fastboot、Recovery基础知识
  6. Android(安卓)SetWallpaper
  7. Android(安卓)rxjava实现倒计时功能
  8. Android中短信拦截解决方案
  9. android 转屏问题
  10. 图片切换