繁体   English   中英

Android的GCM:令牌无效sendRegistrationIdToBackend语法错误

[英]Android GCM: sendRegistrationIdToBackend syntax error on token void

我正在追踪google提供的android GCM教程,并且出现以下错误:

在线上:

private void sendRegistrationIdToBackend() {
  // Your implementation here.

}

令牌“无效”的语法错误,@预期。

语法错误插入“枚举标识符”以完成EnumHeader。

使用,编译器1.6

非常感谢。

整个功能:

private void registerInBackground() {
    new AsyncTask() {
        @Override
        protected String doInBackground(Void... params) {
            String msg = "";
            try {
                if (gcm == null) {
                    gcm = GoogleCloudMessaging.getInstance(context);
                }
                regid = gcm.register(SENDER_ID);
                msg = "Device registered, registration ID=" + regid;

                // You should send the registration ID to your server over HTTP,
                // so it can use GCM/HTTP or CCS to send messages to your app.
                // The request to your server should be authenticated if your app
                // is using accounts.
                sendRegistrationIdToBackend();

                // For this demo: we don't need to send it because the device
                // will send upstream messages to a server that echo back the
                // message using the 'from' address in the message.

                // Persist the regID - no need to register again.
                storeRegistrationId(context, regid);
            } catch (IOException ex) {
                msg = "Error :" + ex.getMessage();
                // If there is an error, don't just keep trying to register.
                // Require the user to click a button again, or perform
                // exponential back-off.
            }
            return msg;
        }

        @Override
        protected void onPostExecute(String msg) {
            mDisplay.append(msg + "\n");
        }
    }.execute(null, null, null);
    /**
     * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP
     * or CCS to send messages to your app. Not needed for this demo since the
     * device sends upstream messages to a server that echoes back the message
     * using the 'from' address in the message.
     */
    private void sendRegistrationIdToBackend() {
      // Your implementation here.

    }
}

似乎您忘记了关闭registerInBackground()方法。

}.execute(null, null, null);之后添加} }.execute(null, null, null);

另一种查看方法是将private void sendRegistrationIdToBackend() {}放在registerInBackground()方法内,这是错误的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM