大家好,我正在使用谷歌GCM,但出于某种原因,我的GCM互联网服务拒绝在注册事件中醒来 - 我知道我做错了什么我只是想弄清楚...
这是我的清单文件 -
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dmx"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<!-- GCM connects to Internet Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Creates a custom permission so only this app can receive its messages. -->
<permission
android:name="com.dmx.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.dmx.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<!-- Splash Screen -->
<activity android:name="com.dmx.ui.ActivitySplashScreen" >
</activity>
<!-- ActivitySplashScreen Screen -->
<activity android:name="com.dmx.ui.ActivityLoginRegister" >
</activity>
<!-- Login Screen -->
<activity android:name="com.dmx.ui.ActivityLogin" >
</activity>
<!-- Broadcasr Reciever Declaration For Incoming Messages -->
<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" />
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.dmx" />
</intent-filter>
</receiver>
<!-- GCM Service Declaration -->
<service android:name="com.dmx.logic.services.GCMIntentService" ></service>
</application>
</manifest>
和logcat输出 -
04-18 06:53:39.561: D/PowerManagerService(2959): [api] handleWakeLockDeath : release WakeLock : PARTIAL_WAKE_LOCK 'GCM_LIB' (uid=10218, pid=31431, ws=null) (elapsedTime=110364)
04-18 06:53:42.316: W/ActivityManager(2959): Unable to start service Intent { act=com.tmc.logic.services.GCMIntentService } U=0: not found
04-18 06:53:43.821: I/PCWCLIENTTRACE_PushUtil(28180): getPushTypeList : [SPP, GCM]
04-18 06:53:44.826: V/GCMBroadcastReceiver(31887): GCM IntentService class: com.tmc.GCMIntentService
04-18 06:53:44.831: W/ActivityManager(2959): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION flg=0x10 pkg=com.tmc cmp=com.tmc/.GCMIntentService (has extras) } U=0: not found
我已经仔细检查了服务是否嵌套在应用程序中并且还试图通过意图启动...它只是不工作....任何帮助???
答案 0 :(得分:9)
您正在使用com.google.android.gcm.GCMBroadcastReceiver
广播接收器。该类希望intent服务类位于您的应用程序的主程序包中 - com.dmx
。但是,由于您将意图服务放在com.dmx.logic.services
中,因此无法找到它。
您可以在logcat中看到它希望GCMIntentService
位于com.tmc
:
04-18 06:53:44.826:V / GCMBroadcastReceiver(31887):GCM IntentService class:com.tmc.GCMIntentService 04-18 06:53:44.831: W / ActivityManager(2959):无法启动服务Intent { act = com.google.android.c2dm.intent.REGISTRATION flg = 0x10 pkg = com.tmc cmp = com.tmc / .GCMIntentService(有额外内容)} U = 0:找不到
您应该将意图服务类移动到主程序包,或者更改广播接收器以在其当前位置查找它。