我想在我的应用中实现推送通知。
我可以在我的设备中收到通知。但我得到一些错误信息。
02-23 15:33:31.904 17918-17918 / com.radaee.reader E / FirebaseInstanceId:无法解析目标意图服务,跳过了类名强制执行<> 02-23 15:33:31.904 17918-17918 / com.radaee.reader E / FirebaseInstanceId:传递消息时出错:未找到ServiceIntent。
02-23 15:33:31.904 17918-22512 / com.radaee.reader W / Bundle:Key google.sent_time expected String但value是java.lang.Long。返回了默认值。
--------- / dev / log / system的开头 02-23 15:33:31.914 17918-22512 / com.radaee.reader W / Bundle:尝试投射生成的内部异常:
java.lang.ClassCastException:java.lang.Long无法强制转换为java.lang.String
在android.os.Bundle.getString(Bundle.java:1121)
在com.google.android.gms.gcm.zza.zzae(未知来源)
在com.google.android.gms.gcm.GcmListenerService.zzo(未知来源)
在com.google.android.gms.gcm.GcmListenerService.zzn(未知来源)
在com.google.android.gms.gcm.GcmListenerService.zzm(未知来源)
在com.google.android.gms.gcm.GcmListenerService.zza(未知来源)
在com.google.android.gms.gcm.GcmListenerService $ 1.run(未知来源)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)
在java.lang.Thread.run(Thread.java:841)
02-23 15:33:31.914 17918-22512 / com.radaee.reader D / MyGcmListenerService:onMessageReceived
02-23 15:33:31.914 17918-22512 / com.radaee.reader D / MyGcmListenerService:From:631033776588
02-23 15:33:31.914 17918-22512 / com.radaee.reader D / MyGcmListenerService:消息:Bundle [{google.sent_time = 1487835190910,key1 = testtesttest,key2 = message2,type = notification,google.message_id = 0: 1487835190917734%768342b8768342b8,notification = Bundle [{body = 432432,icon = ic_launcher,title = PDF Upload}],collapse_key = com.radaee.reader}]
02-23 15:33:31.914 17918-22512 / com.radaee.reader D / MyGcmListenerService:type:notification
02-23 15:33:31.914 17918-22512 / com.radaee.reader D / MyGcmListenerService:show notification
的AndroidManifest.xml
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.push.test.permission.C2D_MESSAGE" />
<permission android:name="com.push.test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<supports-screens android:largeScreens="true" android:anyDensity="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:xlargeScreens="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.radaee.reader.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- [START gcm_receiver] -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.radaee.reader" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.radaee.reader" />
</intent-filter>
</receiver>
<service
android:name="com.radaee.reader.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.radaee.reader.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name="com.radaee.reader.RegistrationIntentService"
android:exported="false">
</service>
</application><uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.push.test.permission.C2D_MESSAGE" />
<permission android:name="com.push.test.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<supports-screens android:largeScreens="true" android:anyDensity="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:xlargeScreens="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.radaee.reader.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- [START gcm_receiver] -->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.radaee.reader" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.radaee.reader" />
</intent-filter>
</receiver>
<service
android:name="com.radaee.reader.MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.radaee.reader.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name="com.radaee.reader.RegistrationIntentService"
android:exported="false">
</service>
</application>
感谢您的帮助!!
答案 0 :(得分:0)
String和Long是完全不同的类型,你无法强制转换 java.lang.ClassCastException:java.lang.Long无法强制转换为java.lang.String
希望这有帮助!