谷歌处理C2DM意图的服务? [英] Handle Google C2DM intents in a service?

查看:209
本文介绍了谷歌处理C2DM意图的服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我成立了自己的Andr​​oid清单XML文件正确,我可以处理C2DM意图(注册和接收)在常规服务,而不是广播接收器?

If I set up my Android Manifest XML file correctly, can I handle C2DM intents (REGISTRATION and RECEIVE) in a regular service, rather than a broadcast receiver?

显然,应用程序将需要为此而设计的,但我只是好奇,如果有可能,或者什么限制了C2DM意图到广播接收器,因为每个例子中,我看网上使用的广播接收器,但在我看来,人们可以使用服务也是如此。

Clearly, the application would need to be designed for this, but I'm just curious if it's possible or if something is limiting the C2DM intents to a broadcast receiver, as every example I've read online uses a broadcast receiver, but it seems to me one could use a service as well.

推荐答案

从引用的谷歌在Android设备上的应用程序并不需要运行以接收消息。当邮件到达时,只要应用程序设置了正确的广播接收器和权限,系统将唤醒通过意向广播应用程序。

所以,没有。接收的消息的唯一方式是广播接收机内。这没什么大不了的。通常,您收到消息,然后调用一个服务。谷歌甚至提供了一个标准的实现。谷歌的IO会议的Andr​​oid +应用程序引擎:开发者的梦幻组合使用向导(见下文为安装)生成code。

So, no. The only way to receive the messages is within a broadcast receiver. This is no big deal. Normally you receive the message and then you call a service. Google even provides you with an standard implementation. The Google IO session Android + App Engine: A Developer’s Dream Combination uses a wizard (see below for the installation) to generate the code.

搜索 C2DMBaseReceiver C2DMBroadcastReceiver C2DMessaging 的例如,在ChromeToPhone <一href=\"http://$c$c.google.com/p/chrometophone/source/browse/trunk/android/c2dm/com/google/android/c2dm/?r=18\"相对=nofollow> code :你有这3个班做的是提供一个类 C2DMReceiver 从<$ C $继承C> C2DMBaseReceiver 并设置明显的。

Search for C2DMBaseReceiver, C2DMBroadcastReceiver and C2DMessaging for example in the ChromeToPhone code: all you have to do with these 3 classes is to provide a class C2DMReceiver which inherits from C2DMBaseReceiver and set up the manifest.

更新结果
谷歌bloggt了解客户端登录密钥过期 。因此,我预计,该插件被更新,包括来源,与该交易。相比于上述一些事情改变了会议的视频。首先,你必须安装Android向导额外的(它不是谷歌插件的一部分):
结果
如视频所描述,那么你必须使用此向导:结果
在生成的项目中,你可以找到 c2dm.jar C2DM-sources.jar 。这些文件有s preaded所有在互联网上,但没有一个归属位置下载最新版本。所以,你必须通过向导生成它们。源不包括版本注释,不与密钥过期问题处理。

Update
Google bloggt about Client Login key expiration. Therefore I expected that the plugin gets updated to include source which deals with that. Compared to the session video above some things changed. First you have to install the android wizard extra (it is not part of the Google plugin):
Then as described in the video you have to use this wizard:
In the generated project you can find c2dm.jar and c2dm-sources.jar. These files are spreaded all over the internet, but don't have a home location to download the latest version. So you have to generate them via the wizard. The source doesn't include a version comment and doesn't deal with the key expiration issues.

这篇关于谷歌处理C2DM意图的服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆