问题描述
我要实现谷歌云通讯服务CCM。但我正在逐渐被迫关闭的错误。我调试在实际设备中的code。 我的Main.java code是如下:
包com.imran.fgcm;
进口com.google.android.gcm.GCMRegistrar;
进口android.os.Bundle;
进口android.app.Activity;
进口android.widget.Toast;
公共类主要扩展活动{
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(本);
GCMRegistrar.checkManifest(本);
最后弦乐REGID = GCMRegistrar.getRegistrationId(本);
如果(regId.equals()){
GCMRegistrar.register(这一点,123450000);
Toast.makeText(这一点,REGID,Toast.LENGTH_LONG).show();
} 其他 {
// Log.v(TAG,已登记);
Toast.makeText(这一点,已登记,Toast.LENGTH_LONG).show();
}
和我的Android清单文件是code是如下:
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.imran.fgcm
安卓版code =1
机器人:VERSIONNAME =1.0>
<用途-SDK
安卓的minSdkVersion =15
机器人:targetSdkVersion =15/>
<允许机器人:名称=com.imran.fgcm.permission.C2D_MESSAGE安卓的ProtectionLevel =签名/>
<使用-权限的Android:名称=com.imran.fgcm.permission.C2D_MESSAGE/>
<使用-权限的Android:名称=com.google.android.c2dm.permission.RECEIVE/>
<使用-权限的Android:名称=android.permission.INTERNET对/>
<使用-权限的Android:名称=android.permission.GET_ACCOUNTS/>
<使用-权限的Android:名称=android.permission.WAKE_LOCK/>
<应用
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:主名称=
机器人:标签=@字符串/ title_activity_main>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
<接收器的Android版本:NAME =com.google.android.gcm.GCMBroadcastReceiver安卓权限=com.google.android.c2dm.permission.SEND>
<意向滤光器>
<作用机器人:名称=com.google.android.c2dm.intent.RECEIVE/>
<作用机器人:名称=com.google.android.c2dm.intent.REGISTRATION/>
<类机器人:名称=com.imran.fgcm/>
&所述; /意图滤光器>
< /接收器>
<服务机器人。GCMIntentServiceNAME = />
< /用途>
< /舱单>
现在它已经停止给强行关闭出错后我加入了GCMIntetservice.java类。但它仍然没有genrerating设备ID。我的logcat输出
11月一号至三号:34:01.023:V / GCMRegistrar(6469):注册接收器
一十一月1日至3日:34:01.023:D / GCMRegistrar(6469):重置退避的com.imran.fgcm
一十一月1日至3日:34:01.058:V / GCMRegistrar(6469):注册发件人732773857047的应用程序com.imran.fgcm
一十一月1日至3日:34:01.288:D / TextLayoutCache(6469):使用调试级别:0 - 调试启用:0
一十一月1日至3日:34:01.843:D /剪贴板(6469):隐藏剪贴板对话框,在开始输入:由别人完成了...!
一十一月1日至3日:34:03.138:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.c2dm.intent.REGISTRATION
一十一月1日至3日:34:03.138:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:03.138:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:03.143:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-1
一十一月1日至3日:34:03.148:D / GCMBaseIntentService(6469):handleRegistration:registrationId = NULL,错误= SERVICE_NOT_AVAILABLE,未注册= NULL
一十一月1日至3日:34:03.148:D / GCMBaseIntentService(6469):注册错误:SERVICE_NOT_AVAILABLE
一十一月1日至3日:34:03.148:D / GCMBaseIntentService(6469):计划报名重试,退避= 4143(3000)
一十一月1日至3日:34:03.213:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:07.318:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.gcm.intent.RETRY
一十一月1日至3日:34:07.318:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:07.318:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:07.353:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-2
一十一月1日至3日:34:07.368:V / GCMRegistrar(6469):注册发件人732773857047的应用程序com.imran.fgcm
一十一月1日至3日:34:07.398:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:07.443:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.c2dm.intent.REGISTRATION
一十一月1日至3日:34:07.443:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:07.443:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:07.453:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-3
一十一月1日至3日:34:07.458:D / GCMBaseIntentService(6469):handleRegistration:registrationId = NULL,错误= SERVICE_NOT_AVAILABLE,未注册= NULL
一十一月1日至3日:34:07.458:D / GCMBaseIntentService(6469):注册错误:SERVICE_NOT_AVAILABLE
一十一月1日至3日:34:07.458:D / GCMBaseIntentService(6469):计划报名重试,退避= 7873(6000)
一十一月1日至3日:34:07.503:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:07.508:D / dalvikvm(6469):GC_CONCURRENT释放213K,免费4%12852K / 13319K,暂停3毫秒+ 3ms的
一十一月1日至3日:34:15.343:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.gcm.intent.RETRY
一十一月1日至3日:34:15.343:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:15.343:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:15.378:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-4
一十一月1日至3日:34:15.393:V / GCMRegistrar(6469):注册发件人732773857047的应用程序com.imran.fgcm
一十一月1日至3日:34:15.428:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:15.498:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.c2dm.intent.REGISTRATION
一十一月1日至3日:34:15.498:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:15.498:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:15.503:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-5
一十一月1日至3日:34:15.508:D / GCMBaseIntentService(6469):handleRegistration:registrationId = NULL,错误= SERVICE_NOT_AVAILABLE,未注册= NULL
一十一月1日至3日:34:15.508:D / GCMBaseIntentService(6469):注册错误:SERVICE_NOT_AVAILABLE
一十一月1日至3日:34:15.508:D / GCMBaseIntentService(6469):计划报名重试,退避= 7347(12000)
一十一月1日至3日:34:15.538:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:22.863:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.gcm.intent.RETRY
一十一月1日至3日:34:22.863:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:22.863:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:22.908:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-6
一十一月1日至3日:34:22.923:V / GCMRegistrar(6469):注册发件人732773857047的应用程序com.imran.fgcm
一十一月1日至3日:34:22.958:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:22.968:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.c2dm.intent.REGISTRATION
一十一月1日至3日:34:22.968:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:22.968:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:22.978:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-7
一十一月1日至3日:34:22.978:D / GCMBaseIntentService(6469):handleRegistration:registrationId = NULL,错误= SERVICE_NOT_AVAILABLE,未注册= NULL
一十一月1日至3日:34:22.983:D / GCMBaseIntentService(6469):注册错误:SERVICE_NOT_AVAILABLE
一十一月1日至3日:34:22.983:D / GCMBaseIntentService(6469):计划报名重试,退避= 35123(24000)
一十一月1日至3日:34:23.013:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:58.113:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.gcm.intent.RETRY
一十一月1日至3日:34:58.118:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:58.118:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:58.153:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-8
一十一月1日至3日:34:58.168:V / GCMRegistrar(6469):注册发件人732773857047的应用程序com.imran.fgcm
一十一月1日至3日:34:58.203:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:34:58.228:V / GCMBroadcastReceiver(6469):的onReceive:com.google.android.c2dm.intent.REGISTRATION
一十一月1日至3日:34:58.228:V / GCMBroadcastReceiver(6469):GCM IntentService类:com.imran.fgcm.GCMIntentService
一十一月1日至3日:34:58.228:V / GCMBaseIntentService(6469):收购wakelock
一十一月1日至3日:34:58.233:V / GCMBaseIntentService(6469):意图服务名称:GCMIntentService-732773857047-9
一十一月1日至3日:34:58.238:D / GCMBaseIntentService(6469):handleRegistration:registrationId = NULL,错误= SERVICE_NOT_AVAILABLE,未注册= NULL
一十一月1日至3日:34:58.238:D / GCMBaseIntentService(6469):注册错误:SERVICE_NOT_AVAILABLE
一十一月1日至3日:34:58.238:D / GCMBaseIntentService(6469):计划报名重试,退避= 67761(48000)
一十一月1日至3日:34:58.268:V / GCMBaseIntentService(6469):释放wakelock
一十一月1日至3日:35:50.863:D /剪贴板(6469):隐藏剪贴板对话框,在开始输入:由别人完成了...!
一十一月1日至3日:35:52.688:E / ActivityThread(6469):活动com.imran.fgcm.Main渗漏最初注册到了这里IntentReceiver com.google.android.gcm.GCMBroadcastReceiver@41903ec8。是否缺少调用unregisterReceiver()?
一十一月1日至3日:35:52.688:E / ActivityThread(6469):android.app.IntentReceiverLeaked:活动com.imran.fgcm.Main渗漏最初注册到了这里IntentReceiver com.google.android.gcm.GCMBroadcastReceiver@41903ec8。是否缺少调用unregisterReceiver()?
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.LoadedApk $ ReceiverDispatcher< INIT>(LoadedApk.java:763)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:567)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1118)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.ContextImpl.registerReceiver(ContextImpl.java:1105)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.content.ContextWrapper.registerReceiver(ContextWrapper.java:355)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在com.google.android.gcm.GCMRegistrar.setRetryBroadcastReceiver(GCMRegistrar.java:293)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在com.google.android.gcm.GCMRegistrar.register(GCMRegistrar.java:215)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在com.imran.fgcm.Main.onCreate(Main.java:19)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.Activity.performCreate(Activity.java:4470)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.ActivityThread.access $ 600(ActivityThread.java:127)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1158)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.os.Handler.dispatchMessage(Handler.java:99)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.os.Looper.loop(Looper.java:137)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在android.app.ActivityThread.main(ActivityThread.java:4511)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在java.lang.reflect.Method.invokeNative(本机方法)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在java.lang.reflect.Method.invoke(Method.java:511)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:980)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
一十一月1日至3日:35:52.688:E / ActivityThread(6469):在dalvik.system.NativeStart.main(本机方法)
一十一月1日至3日:36:06.028:V / GCMRegistrar(6860):注册接收器
一十一月1日至3日:36:06.033:D / GCMRegistrar(6860):重置退避的com.imran.fgcm
一十一月1日至3日:36:06.053:V / GCMRegistrar(6860):注册发件人732773857047的应用程序com.imran.fgcm
一十一月1日至3日:36:06.093:D / TextLayoutCache(6860):使用调试级别:0 - 调试启用:0
一十一月1日至3日:36:06.178:D /剪贴板(6860):隐藏剪贴板对话框,在开始输入:由别人完成了...!
一十一月1日至3日:36:06.203:V / GCMBroadcastReceiver(6860):的onReceive:com.google.android.c2dm.intent.REGISTRATION
一十一月1日至3日:36:06.203:V / GCMBroadcastReceiver(6860):GCM IntentService类:com.imran.fgcm.GCMIntentService
1月3号11:36:06.203:V / GCMBaseIntentService(6860):获取wakelock
一十一月1日至3日:36:06.218:V / GCMBaseIntentService(6860):意图服务名称:GCMIntentService-732773857047-1
一十一月1日至3日:36:06.238:D / GCMBaseIntentService(6860):handleRegistration:registrationId = NULL,错误= SERVICE_NOT_AVAILABLE,未注册= NULL
一十一月1日至3日:36:06.238:D / GCMBaseIntentService(6860):注册错误:SERVICE_NOT_AVAILABLE
一十一月1日至3日:36:06.238:D / GCMBaseIntentService(6860):计划报名重试,退避= 2363(3000)
一十一月1日至3日:36:06.263:V / GCMBaseIntentService(6860):释放wakelock
一十一月1日至3日:36:08.618:V / GCMBroadcastReceiver(6860):的onReceive:com.google.android.gcm.intent.RETRY
一十一月1日至3日:36:08.618:V / GCMBroadcastReceiver(6860):GCM IntentService类:com.imran.fgcm.GCMIntentService
1月3号11:36:08.618:V / GCMBaseIntentService(6860):获取wakelock
一十一月1日至3日:36:08.653:V / GCMBaseIntentService(6860):意图服务名称:GCMIntentService-732773857047-2
一十一月1日至3日:36:08.668:E / GCMBaseIntentService(6860):收到无效的令牌:1111101101100100100110110001110011001001010011110110001010010110
一十一月1日至3日:36:08.668:V / GCMBaseIntentService(6860):释放wakelock
要收到通知,你需要重写从GCMIntentService类onMessage方法如下:
@覆盖
保护无效的onMessage(背景为arg0,意图ARG1){
Log.d(GCM,收到了一条消息);
//从意图获取数据并发送至notificaion吧
generateNotification(为arg0,arg1.getStringExtra(** mymsg **));
}
在这里mymsg我要与你的PHP邮件属性相匹配。请注意,这两个名字应该在PHP是相同的,在Android中,否则您将不会收到通知。
i want to implement google cloud messaging service CCM. but i am getting forced closed error. i am debugging the code on real device. My Main.java code is as below:
package com.imran.fgcm;
import com.google.android.gcm.GCMRegistrar;
import android.os.Bundle;
import android.app.Activity;
import android.widget.Toast;
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
GCMRegistrar.register(this, "123450000");
Toast.makeText(this, regId , Toast.LENGTH_LONG).show();
} else {
// Log.v(TAG, "Already registered");
Toast.makeText(this, "Already registered" , Toast.LENGTH_LONG).show();
}
and my android manifest file is code is as below:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.imran.fgcm"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<permission android:name="com.imran.fgcm.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.imran.fgcm.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Main"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.imran.fgcm" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</application>
</manifest>
now it had stopped giving forced closed error after i added the GCMIntetservice.java class. but it is still not genrerating the device id. My logcat output is
01-03 11:34:01.023: V/GCMRegistrar(6469): Registering receiver
01-03 11:34:01.023: D/GCMRegistrar(6469): resetting backoff for com.imran.fgcm
01-03 11:34:01.058: V/GCMRegistrar(6469): Registering app com.imran.fgcm of senders 732773857047
01-03 11:34:01.288: D/TextLayoutCache(6469): Using debug level: 0 - Debug Enabled: 0
01-03 11:34:01.843: D/CLIPBOARD(6469): Hide Clipboard dialog at Starting input: finished by someone else... !
01-03 11:34:03.138: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.c2dm.intent.REGISTRATION
01-03 11:34:03.138: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:03.138: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:03.143: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-1
01-03 11:34:03.148: D/GCMBaseIntentService(6469): handleRegistration: registrationId = null, error = SERVICE_NOT_AVAILABLE, unregistered = null
01-03 11:34:03.148: D/GCMBaseIntentService(6469): Registration error: SERVICE_NOT_AVAILABLE
01-03 11:34:03.148: D/GCMBaseIntentService(6469): Scheduling registration retry, backoff = 4143 (3000)
01-03 11:34:03.213: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:07.318: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.gcm.intent.RETRY
01-03 11:34:07.318: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:07.318: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:07.353: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-2
01-03 11:34:07.368: V/GCMRegistrar(6469): Registering app com.imran.fgcm of senders 732773857047
01-03 11:34:07.398: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:07.443: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.c2dm.intent.REGISTRATION
01-03 11:34:07.443: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:07.443: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:07.453: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-3
01-03 11:34:07.458: D/GCMBaseIntentService(6469): handleRegistration: registrationId = null, error = SERVICE_NOT_AVAILABLE, unregistered = null
01-03 11:34:07.458: D/GCMBaseIntentService(6469): Registration error: SERVICE_NOT_AVAILABLE
01-03 11:34:07.458: D/GCMBaseIntentService(6469): Scheduling registration retry, backoff = 7873 (6000)
01-03 11:34:07.503: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:07.508: D/dalvikvm(6469): GC_CONCURRENT freed 213K, 4% free 12852K/13319K, paused 3ms+3ms
01-03 11:34:15.343: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.gcm.intent.RETRY
01-03 11:34:15.343: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:15.343: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:15.378: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-4
01-03 11:34:15.393: V/GCMRegistrar(6469): Registering app com.imran.fgcm of senders 732773857047
01-03 11:34:15.428: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:15.498: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.c2dm.intent.REGISTRATION
01-03 11:34:15.498: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:15.498: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:15.503: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-5
01-03 11:34:15.508: D/GCMBaseIntentService(6469): handleRegistration: registrationId = null, error = SERVICE_NOT_AVAILABLE, unregistered = null
01-03 11:34:15.508: D/GCMBaseIntentService(6469): Registration error: SERVICE_NOT_AVAILABLE
01-03 11:34:15.508: D/GCMBaseIntentService(6469): Scheduling registration retry, backoff = 7347 (12000)
01-03 11:34:15.538: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:22.863: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.gcm.intent.RETRY
01-03 11:34:22.863: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:22.863: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:22.908: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-6
01-03 11:34:22.923: V/GCMRegistrar(6469): Registering app com.imran.fgcm of senders 732773857047
01-03 11:34:22.958: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:22.968: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.c2dm.intent.REGISTRATION
01-03 11:34:22.968: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:22.968: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:22.978: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-7
01-03 11:34:22.978: D/GCMBaseIntentService(6469): handleRegistration: registrationId = null, error = SERVICE_NOT_AVAILABLE, unregistered = null
01-03 11:34:22.983: D/GCMBaseIntentService(6469): Registration error: SERVICE_NOT_AVAILABLE
01-03 11:34:22.983: D/GCMBaseIntentService(6469): Scheduling registration retry, backoff = 35123 (24000)
01-03 11:34:23.013: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:58.113: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.gcm.intent.RETRY
01-03 11:34:58.118: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:58.118: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:58.153: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-8
01-03 11:34:58.168: V/GCMRegistrar(6469): Registering app com.imran.fgcm of senders 732773857047
01-03 11:34:58.203: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:34:58.228: V/GCMBroadcastReceiver(6469): onReceive: com.google.android.c2dm.intent.REGISTRATION
01-03 11:34:58.228: V/GCMBroadcastReceiver(6469): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:34:58.228: V/GCMBaseIntentService(6469): Acquiring wakelock
01-03 11:34:58.233: V/GCMBaseIntentService(6469): Intent service name: GCMIntentService-732773857047-9
01-03 11:34:58.238: D/GCMBaseIntentService(6469): handleRegistration: registrationId = null, error = SERVICE_NOT_AVAILABLE, unregistered = null
01-03 11:34:58.238: D/GCMBaseIntentService(6469): Registration error: SERVICE_NOT_AVAILABLE
01-03 11:34:58.238: D/GCMBaseIntentService(6469): Scheduling registration retry, backoff = 67761 (48000)
01-03 11:34:58.268: V/GCMBaseIntentService(6469): Releasing wakelock
01-03 11:35:50.863: D/CLIPBOARD(6469): Hide Clipboard dialog at Starting input: finished by someone else... !
01-03 11:35:52.688: E/ActivityThread(6469): Activity com.imran.fgcm.Main has leaked IntentReceiver com.google.android.gcm.GCMBroadcastReceiver@41903ec8 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-03 11:35:52.688: E/ActivityThread(6469): android.app.IntentReceiverLeaked: Activity com.imran.fgcm.Main has leaked IntentReceiver com.google.android.gcm.GCMBroadcastReceiver@41903ec8 that was originally registered here. Are you missing a call to unregisterReceiver()?
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:763)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:567)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1118)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1105)
01-03 11:35:52.688: E/ActivityThread(6469): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:355)
01-03 11:35:52.688: E/ActivityThread(6469): at com.google.android.gcm.GCMRegistrar.setRetryBroadcastReceiver(GCMRegistrar.java:293)
01-03 11:35:52.688: E/ActivityThread(6469): at com.google.android.gcm.GCMRegistrar.register(GCMRegistrar.java:215)
01-03 11:35:52.688: E/ActivityThread(6469): at com.imran.fgcm.Main.onCreate(Main.java:19)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.Activity.performCreate(Activity.java:4470)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.ActivityThread.access$600(ActivityThread.java:127)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
01-03 11:35:52.688: E/ActivityThread(6469): at android.os.Handler.dispatchMessage(Handler.java:99)
01-03 11:35:52.688: E/ActivityThread(6469): at android.os.Looper.loop(Looper.java:137)
01-03 11:35:52.688: E/ActivityThread(6469): at android.app.ActivityThread.main(ActivityThread.java:4511)
01-03 11:35:52.688: E/ActivityThread(6469): at java.lang.reflect.Method.invokeNative(Native Method)
01-03 11:35:52.688: E/ActivityThread(6469): at java.lang.reflect.Method.invoke(Method.java:511)
01-03 11:35:52.688: E/ActivityThread(6469): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
01-03 11:35:52.688: E/ActivityThread(6469): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
01-03 11:35:52.688: E/ActivityThread(6469): at dalvik.system.NativeStart.main(Native Method)
01-03 11:36:06.028: V/GCMRegistrar(6860): Registering receiver
01-03 11:36:06.033: D/GCMRegistrar(6860): resetting backoff for com.imran.fgcm
01-03 11:36:06.053: V/GCMRegistrar(6860): Registering app com.imran.fgcm of senders 732773857047
01-03 11:36:06.093: D/TextLayoutCache(6860): Using debug level: 0 - Debug Enabled: 0
01-03 11:36:06.178: D/CLIPBOARD(6860): Hide Clipboard dialog at Starting input: finished by someone else... !
01-03 11:36:06.203: V/GCMBroadcastReceiver(6860): onReceive: com.google.android.c2dm.intent.REGISTRATION
01-03 11:36:06.203: V/GCMBroadcastReceiver(6860): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:36:06.203: V/GCMBaseIntentService(6860): Acquiring wakelock
01-03 11:36:06.218: V/GCMBaseIntentService(6860): Intent service name: GCMIntentService-732773857047-1
01-03 11:36:06.238: D/GCMBaseIntentService(6860): handleRegistration: registrationId = null, error = SERVICE_NOT_AVAILABLE, unregistered = null
01-03 11:36:06.238: D/GCMBaseIntentService(6860): Registration error: SERVICE_NOT_AVAILABLE
01-03 11:36:06.238: D/GCMBaseIntentService(6860): Scheduling registration retry, backoff = 2363 (3000)
01-03 11:36:06.263: V/GCMBaseIntentService(6860): Releasing wakelock
01-03 11:36:08.618: V/GCMBroadcastReceiver(6860): onReceive: com.google.android.gcm.intent.RETRY
01-03 11:36:08.618: V/GCMBroadcastReceiver(6860): GCM IntentService class: com.imran.fgcm.GCMIntentService
01-03 11:36:08.618: V/GCMBaseIntentService(6860): Acquiring wakelock
01-03 11:36:08.653: V/GCMBaseIntentService(6860): Intent service name: GCMIntentService-732773857047-2
01-03 11:36:08.668: E/GCMBaseIntentService(6860): Received invalid token: 1111101101100100100110110001110011001001010011110110001010010110
01-03 11:36:08.668: V/GCMBaseIntentService(6860): Releasing wakelock
TO receive the Notification you need to override the onMessage method from GCMIntentService class as follows
@Override
protected void onMessage(Context arg0, Intent arg1) {
Log.d("GCM", "RECIEVED A MESSAGE");
// Get the data from intent and send to notificaion bar
generateNotification(arg0, arg1.getStringExtra("**mymsg**"));
}
here "mymsg" should me match with your php message attribute. Please Note that both name should be same in php and in android otherwise you will not receive the notification.
这篇关于安卓GCM实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!