[英]Register app for GCM in android
我正在尝试将GSM集成到我的android应用中。 我可以使用我的Api密钥和Sender_id通过该演示运行GCM-Client-demo应用程序并注册设备,但是当我在应用程序中使用相同代码时,则无法向GCM注册设备。
我在日志猫中得到的错误是。
08-13 11:24:34.787: W/ActivityManager(2465): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION cat=[com.demo.demogcm] cmp=com.demo.demogcm/.GCMIntentService (has extras) }: not found
我的清单文件。
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 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.
NOTE: the permission *must* be called PACKAGE.permission.C2D_MESSAGE,
where PACKAGE is the application's package name.
-->
<permission
android:name="com.demo.demogcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.demo.demogcm.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive data message. -->
<uses-permission
android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".view.DemoActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.demo.demogcm.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.demo.demogcm" />
</intent-filter>
</receiver>
<!--
Application-specific subclass of GCMBaseIntentService that will
handle received messages.
By default, it must be named .GCMIntentService, unless the
application uses a custom BroadcastReceiver that redefines its name.
-->
<service android:name=".view.GCMIntentService" />
</application>
谁能告诉我我在做什么错?
请更换(明示)
带有此android:name =“。GCMIntentService”的 android:name =“。view.GCMIntentService”代码,并将GCMIntentService放在同一包“ com.demo.demogcm”中
您还可以使用以下程序包和类名称: <service android:name=".view.GCMIntentService" />
但带有其他功能
This intent service will be called by the GCMBroadcastReceiver (which is is provided by GCM library), as shown in the next step. It must be a subclass of com.google.android.gcm.GCMBaseIntentService, must contain a public constructor, and should be named my_app_package.GCMIntentService (unless you use a subclass of GCMBroadcastReceiver that overrides the method used to name the service).
这是如何工作的,您可以在这里看到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.