WakefulBroadcastReceiver不能被解析为一个类型 [英] WakefulBroadcastReceiver cannot be resolved to a type
问题描述
我的项目显示错误消息, WakefulBroadcastReceiver不能被解析为一个类型
。
我抬起头,对所有可能的原因,我能想到的。我已经设置 Android的支持库
和谷歌播放服务
的路径。甚至我的MapView作品(如果我下面评论code),这意味着谷歌播放服务
正确添加到项目。
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?
推荐答案
请确保您有最新的Android支持包添加到项目中。例如,此示例项目具有合适 Android的支持-v4.jar
并演示了如何使用 WakefulBroadcastReceiver
。
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
.
这篇关于WakefulBroadcastReceiver不能被解析为一个类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!