大佬教程收集整理的这篇文章主要介绍了从未调用的GCMIntentService中的android – onRegistered(),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的Logcat@H_262_3@
01-17 11:03:00.015: D/GCMRegistrar(3509): resetTing BACkoff for com.abc.xyz.ui.activity 01-17 11:03:03.210: V/GCMRegistrar(3509): Registering app com.abc.xyz.ui.activity of senders 964256581311 01-17 11:03:06.070: V/GCMBroadcastReceiver(3509): onReceive: com.google.android.c2dm.intent.REGISTRATION 01-17 11:03:06.070: V/GCMBroadcastReceiver(3509): GCM Intentservice class: com.abc.xyz.ui.activity.GCMIntentservice 01-17 11:03:06.070: V/GCMBaseIntentservice(3509): Acquiring wakelock
这是我的完整清单@H_262_3@
<?xml version="1.0" encoding="utf-8"?> <manifest package="com.abc.xyz.ui.activity" android:versionCode="1" android:versionName="1.5.6" xmlns:android="http://scheR_98_11845@as.android.com/apk/res/android"> <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="16"/> <uses-feature android:name="android.hardware.usb.host"/> <!-- This app has permission to register and receive data message. --> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.GET_TASKS" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.Call_PHONE" /> <uses-permission android:name="android.permission.bLUETOOTH" /> <!-- 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. --> <uses-permission android:name="com.abc.xyz.ui.activity.permission.C2D_messaGE" /> <permission android:name="com.abc.xyz.ui.activity.permission.C2D_messaGE" android:protectionLevel="signature" /> <application android:icon="@drawable/ic_launcher" android:label="@String/app_name" android:theme="@android:style/Theme.Holo.Light" android:name="com.abc.xyz.MyApplication" android:allowBACkup="false"> <activity android:name=".StartupActivity" android:noHistory="true" android:label="@String/title_startup_screen" android:configChanges="orientation"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".LoginActivity" android:windowSofTinputMode="stateAlwaysVisible|adjustResize" android:label="@String/title_login_screen" android:configChanges="orientation"> </activity> //my other activity defination <!-- BroadcastReceiver that will receivE intents from GCM services and handle them to the custom Intentservice. The com.google.android.c2dm.permission.SEND permission is necessary so only GCM services can send data messages for the app. --> <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.abc.xyz.ui.activity" /> </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="com.abc.xyz.ui.activity.GCMIntentservice" /> </application> </manifest>
我从你的logcat中遗漏了一些日志,这些日志表明你的服务甚至被调用.注册时我在我的Logcat中有这个:@H_262_3@
GCMBroadcastReceiver V onReceive: com.google.android.c2dm.intent.REGISTRATION GCMBroadcastReceiver V GCM Intentservice class: com.package.android.app.GCMIntentservice GCMBaseIntentservice V Acquiring wakelock GCMBaseIntentservice V Intent service name: GCMIntentservice-DynamicSenderIds-1
特别是最后一行丢失或您忘记粘贴它.你能确定你发布了完整的LogCat吗?过滤GCM以确保您没有遗漏任何东西.@H_262_3@
更新@H_262_3@
正如评论中提到的OP,他使用该服务做了更多.这在某种程度上干扰了GCM功能,并在将其分成两个服务之后起作用.经验教训:除了GCM之外,不要将GCMIntentservice用于其他任何事情.@H_262_3@
以上是大佬教程为你收集整理的从未调用的GCMIntentService中的android – onRegistered()全部内容,希望文章能够帮你解决从未调用的GCMIntentService中的android – onRegistered()所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。