Bil*_*hon 6 android android-manifest android-c2dm
我正在尝试测试C2DM框架.我几天前收到了确认电子邮件,然后尝试创建一个可以注册的客户端.为此,我按照本教程中描述的步骤创建了一个简单的客户端:http://code.google.com/intl/es-419/android/c2dm/index.html.
Android清单文件包含以下代码:
<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>
Run Code Online (Sandbox Code Playgroud)
然后,程序启动时启动的主要活动具有以下代码:
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);
Run Code Online (Sandbox Code Playgroud)
我还在运行我的客户端的AVD上注册了一个谷歌帐户,因为他们说这是必需的.但问题是我不能让广播接收器"醒来".我不知道会出现什么问题.通过分析日志,我可以看到注册意图已经创建并且显然正确使用,但是接收器代码从未被执行过,可能出错了什么?
在此先感谢尼尔森
嗯..刚刚整理出来,问题在于接收器的声明.接收器的标签应该放在应用程序标签内,如下所示:http://developer.android.com/guide/topics/manifest/manifest-intro.html
这是一个用于C2DM应用程序的格式良好的Manifest的示例.感谢Mark Murphy在android-c2dm组发布链接.
抱歉这个愚蠢的错误.
纳尔逊
| 归档时间: |
|
| 查看次数: |
15244 次 |
| 最近记录: |