【问题标题】:Android GoogleCloudMessaging cannot be resolved to a typeAndroid GoogleCloudMessaging 无法解析为类型
【发布时间】:2014-11-15 09:54:13
【问题描述】:

我正在尝试访问GoogleCloudMessaging,但我收到GoogleCloudMessaging cannot be resolved to a type 的错误

我在我的项目中添加了 google-play-services,但仍然遇到同样的错误。

我的代码:

private void check() {
        Context ctx = getApplicationContext();
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(ctx);
        String messageType = gcm.getMessageType(PushNotificationService.class);
        Intent notificationIntent = new Intent(ctx, PushNotificationService.class);
        PendingIntent contentIntent = PendingIntent.getActivity(ctx, 596, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
        NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
        Resources res = ctx.getResources();
        Notification.Builder builder = new Notification.Builder(ctx);
        builder.setContentIntent(contentIntent).setSmallIcon(R.drawable.icon).setLargeIcon(BitmapFactory.decodeResource(res, R.drawable.icon)).setTicker("New message").setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentTitle("Welcome").setContentText("Hello World!");
        Notification n = builder.build();
        nm.notify(596, n);
    }

我的项目属性库:

我的项目属性顺序:

SDK 附加功能:

【问题讨论】:

    标签: android google-play-services google-cloud-messaging


    【解决方案1】:

    好的,我解决了,

    我从 sdk manager 中删除了 google play 服务并重新安装。再次导入 JAR,效果很好。

    谢谢。

    【讨论】:

      猜你喜欢
      • 2013-05-13
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 2011-07-14
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多