我已经阅读了有关WakeLock的各种解决方案,例如在AndroidManifest.xml中添加Permission以及确保GCMIntentService的Constructor设置为public.
但是,我的代码仍然停留在"获取Wakelock"
完全相同的代码与单独的Android应用程序分开工作.
我将它集成到我的主应用程序后才遇到此错误.
以下是我的GCM Intent Service代码:
package com.mp2012.ieatishootipostanalyzer.notifications;
import static com.mp2012.ieatishootipostanalyzer.notifications.CommonUtilities.SENDER_ID;
import static com.mp2012.ieatishootipostanalyzer.notifications.CommonUtilities.displayMessage;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.google.android.gcm.GCMBaseIntentService;
import com.mp2012.ieatishootipostanalyzer.R;
import com.mp2012.ieatishootipostanalyzer.notifications.MainActivity2;
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super(SENDER_ID);
}
/**
* Method called on device registered
**/
@Override
protected void onRegistered(Context context, String registrationId) {
Log.i(TAG, "Device registered: regId = " + registrationId);
displayMessage(context, "Your device registred with …Run Code Online (Sandbox Code Playgroud)