我尝试使用此代码通过 gcm 取消注册设备:
btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
GCMRegistrar.unregister(MainActivity.this);
}
});
知道我在onCreate()
方法中使用了此代码...但是当我尝试向DeviceID
通知到达时发送通知时,这意味着取消注册过程没有成功
我的onCreate()
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
txt = (TextView)findViewById(R.id.txt_nn);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals(""))
{
GCMRegistrar.register(this, "344XXXXXXX571");
}
else
{
Log.v("Info : ", "Already registered");
}
txt.setText(regId);
btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
GCMRegistrar.unregister(MainActivity.this);
}
});
}
我的日志猫
12-25 17:16:31.290: E/Trace(18754): error opening trace file: No such file or directory (2)
12-25 17:16:31.425: V/Info :(18754): Already registered
12-25 17:16:31.485: D/libEGL(18754): loaded /system/lib/egl/libEGL_mali.so
12-25 17:16:31.490: D/libEGL(18754): loaded /system/lib/egl/libGLESv1_CM_mali.so
12-25 17:16:31.495: D/libEGL(18754): loaded /system/lib/egl/libGLESv2_mali.so
12-25 17:16:31.500: D/(18754): Device driver API match
12-25 17:16:31.500: D/(18754): Device driver API version: 10
12-25 17:16:31.500: D/(18754): User space API version: 10
12-25 17:16:31.500: D/(18754): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Wed Sep 12 17:53:53 KST 2012
12-25 17:16:31.540: D/OpenGLRenderer(18754): Enabling debug mode 0
12-25 17:16:43.015: D/GestureDetector(18754): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 2 mFalseSizeCnt:0
12-25 17:16:43.020: D/GCMRegistrar(18754): resetting backoff for com.example.test09_gsm
12-25 17:16:43.020: V/GCMRegistrar(18754): Unregistering app com.example.test09_gsm
12-25 17:16:46.865: V/GCMBroadcastReceiver(18754): onReceive: com.google.android.c2dm.intent.REGISTRATION
12-25 17:16:46.865: V/GCMBroadcastReceiver(18754): GCM IntentService class: com.example.test09_gsm.GCMIntentService
12-25 17:16:46.870: V/GCMBaseIntentService(18754): Acquiring wakelock
12-25 17:16:46.895: V/GCMBaseIntentService(18754): Intent service name: GCMIntentService-IntentService-1
12-25 17:16:46.895: E/GCMRegistrar(18754): internal error: retry receiver class not set yet
12-25 17:16:46.895: V/GCMRegistrar(18754): Registering receiver
12-25 17:16:46.895: D/GCMBaseIntentService(18754): handleRegistration: registrationId = null, error = null, unregistered = com.example.test09_gsm
12-25 17:16:46.895: D/GCMRegistrar(18754): resetting backoff for com.example.test09_gsm
12-25 17:16:46.895: V/GCMRegistrar(18754): Saving regId on app version 1
12-25 17:16:46.940: D/onUnregistered(18754): APA91bFrB0pJOQqq7MxSe-so7fbqh70jLpX6bRrcRIdW6py1EuxletPfGr5ZlkytrenbdnJskdWXckjIcHWsvtKXppZ1PsMbhfkzIc9BmX26brIVDTCRSXPey7POA3UqP6EexMD4w_plFQkVy-9pacCqbBfV0k91dQ
12-25 17:16:46.940: V/GCMBaseIntentService(18754): Releasing wakelock
请你帮我在 GCM 上取消注册设备并且不会收到未来的通知
提前致谢