我正在遵循在Android上应用GCM客户端的指南。然而,无法找到我的扩展WakefulBroadcastReceiver(WakefulBroadcastReceiver无法解析)。是因为我的表现吗?我已将所需的包更改为我的项目包,但它没有解决问题
这是我的清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.example.myapplication.permission.C2D_MESSAGE" />
<uses-permission android:name="com.example.myapplication.permission.C2D_MESSAGE" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock.Light" >
<activity
android:name="com.example.myapplication.Login"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.example.myapplication.fragmentContainer" >
</activity>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.example.myapplication" />
</intent-filter>
</receiver>
<service android:name=".GcmIntentService" />
</application>
</manifest>
答案 0 :(得分:1)
发现错误,我的图书馆已经过时了。在eclipse中更新源代码解决了这个问题
答案 1 :(得分:0)
我最近遇到了同样的问题,我做了什么来修复它(在尝试其他所有事情之后)是将我的接收器重命名为:
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!-- Receives the registration id. -->
<category android:name="your.package.name.GCMIntentService" />
</intent-filter>
</receiver>
<service android:name="your.package.name.GCMIntentService" />
还要确保您的GCMBroadcastReciever java文件位于软件包的根目录中。