我正在尝试访问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 Extras:
答案 0 :(得分:0)
好的我解决了这个问题,
我从sdk管理器中删除了google play服务并再次安装。再次导入JAR,它就像魅力一样。
谢谢。