WakefulBroadcastReceiver无法解析为一种类型
我的项目显示错误消息WakefulBroadcastReceiver cannot be resolved to a
type。我出于所有可能想到的原因抬起头来。我已设定android-support-library
和google play
services的路径。即使我的mapView可以正常工作(如果我在下面的代码中评论),这意味着google play
service已正确添加到项目中。
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);
}
}
知道为什么会出错吗?
回答:
确保您已将最新的Android支持程序包添加到项目中。例如,此示例项目有一个合适的示例,android-
support-v4.jar并演示了的用法WakefulBroadcastReceiver
。
以上是 WakefulBroadcastReceiver无法解析为一种类型 的全部内容, 来源链接: utcz.com/qa/401681.html