0
我正在用Google Cloud Messaging
librarys構建應用程序。儘管帶有API 15的設備工作良好,但設備(API 10)仍然存在問題。設備自動從GCM取消註冊,出現空錯誤
API 10的問題, 首先,設備能夠註冊GCM並能夠在註冊期間生成註冊ID。但是,當消息從服務器發送到設備時,應用程序會自動調用GCMintent service class
中的onUnregistered
方法,並且還會爲該錯誤提供空值。如下所示
以下是我的代碼。
// This is the GCMIntentService class
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super("IntentService");
}
/**
* Method called on device registered
**/
@Override
protected void onRegistered(Context context, String registrationId) {
Log.i(TAG, "Device registered: regId = " + registrationId);
}
/**
* Method called on Receiving a new message
* */
@Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
}
/**
* Method called on device un registred
* */
@Override
protected void onUnregistered(Context context, String registrationId) {
Log.i(TAG, "Device unregistered from the app");
}
/**
* Method called on receiving a deleted message
* */
@Override
protected void onDeletedMessages(Context context, int total) {
Log.i(TAG, "Received deleted messages notification");
}
/**
* Method called on Error
* */
@Override
public void onError(Context context, String errorId) {
Log.i(TAG, "Received error: " + errorId);
//displayMessage(context, getString(R.string.gcm_error, errorId));
}
@Override
protected boolean onRecoverableError(Context context, String errorId) {
// log message
Log.i(TAG, "Received recoverable error: " + errorId);
return super.onRecoverableError(context, errorId);
}
}
/**
* The log cat summary when the message is sent to the app
*/
10-07 13:24:20.484 9792-9792/com.ankoibia.maiddadfmd V/GCMBroadcastReceiver﹕ onReceive: com.google.android.c2dm.intent.REGISTRATION
10-07 13:24:20.484 9792-9792/com.ankoibia.maiddadfmd V/GCMBroadcastReceiver﹕ GCM IntentService class: com.ankoibia.maiddadfmd.GCMIntentService
10-07 13:24:20.515 9792-9792/com.ankoibia.maiddadfmd V/GCMBaseIntentService﹕ Acquiring wakelock
10-07 13:24:20.546 9792-9792/com.ankoibia.maiddadfmd V/GCMBaseIntentService﹕ Intent service name: GCMIntentService-IntentService-1
10-07 13:24:20.546 9792-9956/com.ankoibia.maiddadfmd E/GCMRegistrar﹕ internal error: retry receiver class not set yet
10-07 13:24:20.546 9792-9956/com.ankoibia.maiddadfmd V/GCMRegistrar﹕ Registering receiver
10-07 13:24:20.570 9792-9956/com.ankoibia.maiddadfmd D/GCMBaseIntentService﹕ handleRegistration: registrationId = null, error = null, unregistered = com.ankoibia.maiddadfmd
10-07 13:24:20.570 9792-9956/com.ankoibia.maiddadfmd D/GCMRegistrar﹕ resetting backoff for com.ankoibia.maiddadfmd
10-07 13:24:20.585 9792-9956/com.ankoibia.maiddadfmd V/GCMRegistrar﹕ Saving regId on app version 1
10-07 13:24:20.585 9792-9956/com.ankoibia.maiddadfmd I/GCMIntentService﹕ Device unregistered from the app
10-07 13:24:20.585 9792-9956/com.ankoibia.maiddadfmd V/GCMBaseIntentService﹕ Releasing wakelock
請問我有什麼需要做的嗎?如果有人能幫助我,我將不勝感激。謝謝