小编Dil*_*egi的帖子

无法解析符号'GoogleCloudMessaging'GCM

我正在尝试GCM在我的应用程序中工作(在我们的工作时间更改时或在我们有任何促销活动时通知用户),但Cannot resolve symbol 'GoogleCloudMessaging'在尝试使用Google Cloud Messaging API时我一直收到错误消息.

我正在使用新发布的Android工作室IDE来编写代码.

这是我的GcmBroadcastReciever.java代码:

import android.R;
import android.app.Activity;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class GcmBroadcastReceiver extends BroadcastReceiver 
{
    static final String TAG = "GCMDemo";
    public static final int NOTIFICATION_ID = 1;
    private NotificationManager mNotificationManager;
    Context ctx;
    GoogleCloudMessaging gcm; // I get the error here

    @Override
    public void onReceive(Context context, Intent intent) {
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); //error
        ctx = context;
        String messageType = …
Run Code Online (Sandbox Code Playgroud)

java android push-notification google-cloud-messaging android-studio

30
推荐指数
3
解决办法
4万
查看次数