Skip to content
Advertisement

WakefulBroadcastReceiver cannot be resolved to a type

My project shows error message that WakefulBroadcastReceiver cannot be resolved to a type. I looked up for all possible reasons I can think of. I have set android-support-library and google play services‘s path. Even my mapView works (if I comment below code) that means google play service is correctly added to project.

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // Explicitly specify that GcmIntentService will handle the intent.
        ComponentName comp = new ComponentName(context.getPackageName(),
            GcmIntentService.class.getName());
        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}

Any idea why this gives error?

Advertisement

Answer

Make sure that you have the latest Android Support package added to your project. For example, this sample project has a suitable android-support-v4.jar and demonstrates the use of WakefulBroadcastReceiver.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement