问题在Android中注册的C2DM [英] Problem registering for C2DM in Android

查看:112
本文介绍了问题在Android中注册的C2DM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试C2DM框架。我一前两天拿到了确认电子邮件,然后tryied创建可以注册一个客户端。为此,我创建了下面这个教程中描述的步骤,一个简单的客户端:<一href="http://$c$c.google.com/intl/es-419/android/c2dm/index.html">http://$c$c.google.com/intl/es-419/android/c2dm/index.html.

I'm trying to test the C2DM framework. I got the confirmation email a couple of days ago and then tryied to create a client that could register. For that purpose, I created a simple client following the steps described in this tutorial: http://code.google.com/intl/es-419/android/c2dm/index.html.

Android清单文件中包含除其他事项外本code:

The Android manifest file contains among other things this code:

<permission android:name="com.bilthon.ufrj.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.bilthon.ufrj.permission.C2D_MESSAGE" />

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<uses-permission android:name="android.permission.INTERNET"/>

<receiver android:name=".C2DMReceiver" android:permission="com.google.android.c2dm.permission.SEND">

<intent-filter>
   <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
   <category android:name="com.bilthon.ufrj" />
</intent-filter>

<intent-filter>
   <action android:name="com.google.android.c2dm.intent.RECEIVE" />
   <category android:name="com.bilthon.ufrj" />
</intent-filter>
</receiver>

然后,在程序启动时有如下code的主要活动启动:

And then, the main activity launched when the program starts has the following code:

Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
registrationIntent.putExtra("sender","mytestemail@gmail.com");
Log.d("WelcomeScreen","mytestemail@gmail.com");
startService(registrationIntent);

我也注册了运行我的客户端上的AVD一个谷歌帐户,因为他们说,这是必需的。但问题是,我不能让广播接收器唤醒。我不知道什么可能是错误的。通过分析日志,我可以看到,登记的意图是创建和显然正确地使用,但接收器code只是从来没有被执行,这可能是错的?

I also registered a google account on the AVD running my client, as they said it was required. But the problem is that I cannot get the broadcast receiver to "wake up". I don't know what could be wrong. By analysing the logs, I can see that the registration intent is created and apparently used correctly, but the receiver code just never is executed, what could be wrong?

在此先感谢 尼尔森

推荐答案

嗯..刚整理出来的问题是与接收器的声明。该标签接收器应该去申请标签中,就像这里演示:<一href="http://developer.android.com/guide/topics/manifest/manifest-intro.html">http://developer.android.com/guide/topics/manifest/manifest-intro.html

Well.. just sorted it out, the problem was with the declaration of the receiver. The tags for the receiver should go inside the application tag, just as demonstrated here: http://developer.android.com/guide/topics/manifest/manifest-intro.html

下面是一个很好格式化舱单的C2DM应用的一个例子。感谢马克·墨菲张贴在Android的C2DM组的链接。

Here's an example of a well formated Manifest for a C2DM application. Thanks to Mark Murphy for posting the link at the android-c2dm group.

和遗憾的愚蠢的错误。

尼尔森

这篇关于问题在Android中注册的C2DM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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