android系统中低于4.1谷歌云消息 [英] google cloud messaging in android lower than 4.1

查看:160
本文介绍了android系统中低于4.1谷歌云消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用推送通知(GCM),当在Android 4.2.2(银河Nexus和HTC一)

I'm using push notifications (GCM) in my application and it works correctly when run on android 4.2.2 (Galaxy Nexus and HTC One)

另外我有一个平板电脑(ASUS变压器T101运行Android 4.03)和歌Nexus One(运行Android 2.3.6)

Also I have a tablet (asus transformer T101 running android 4.03) and Nexus One (running Android 2.3.6)

运行在平板电脑上的应用和Nexus One的,推送通知的方法不起作用。

Running the application on the tablet and the Nexus one, methods of push notifications do not work.

如文档中表示,我已经包含android.permission.GET_ACCOUNTS低于4.0.3版本的许可,但没有成功。

As indicated in the documentation, I have included android.permission.GET_ACCOUNTS the permission for versions below 4.0.3, but without success.

这GCM调用的库的方法运行:

The method that calls the library of GCM runs:

final String regId = GCMRegistrar.getRegistrationId(Hello.this);
        if (regId.equals("")) {
            GCMRegistrar.register(Hola.this, "MY_ID_SENDER"); //Sender ID           
        } else {
            Log.i("masterhv", "already registered");
        }

但不执行处理的响应方法(onRegistered)......据我所知,没有来自谷歌回应

But the method that handles the response is not executed (onRegistered) ... I understand that there is no response from Google

正如我所说的,它完美搭载Android 4.2.2和4.1,权限是正确的设备,但在Android 4.0.3,下不能正常工作。

As I said, it works perfectly on devices with android 4.2.2 and 4.1, permissions are correct, but does not work on android 4.0.3 and lower.

我AP preciate任何帮助。

I appreciate any help.

感谢和问候

推荐答案

与旧版本的GCM(德precated 1-2个月前近似),你不得不问给用户,如果添加一个谷歌帐户他跑一个版本低于4.0.4

With the old version of GCM (deprecated 1-2 month ago aprox.) you had to ask to the user to add a google account if he was running a version lower than 4.0.4

在API文档看它仍然是一个要求

Looking at the API docs it is still a requirement

移动设备正在运行使用GCM一个Android应用程序的设备。这必须是安装了谷歌Play商店中的2.2的Andr​​oid设备,而且必须在谷歌帐户登录至少一个,如果该设备正在运行的版本比Android 4.0.4低。另外,测试你可以使用运行Android 2.2与谷歌的API的仿真器。

Mobile Device The device that is running an Android application that uses GCM. This must be a 2.2 Android device that has Google Play Store installed, and it must have at least one logged in Google account if the device is running a version lower than Android 4.0.4. Alternatively, for testing you can use an emulator running Android 2.2 with Google APIs.

GCM API

我没有使用过的最后一个版本。如果您决定使用旧的已生成的存取权限的帐户设置,添加帐户:

I have not used the last version. If you decide to use the old one you have to generate an acces to the account settings to add an account:

private String[] getAccountNames() {        
        AccountManager accMan = AccountManager.get(this);
        Account[] accArray = accMan.getAccountsByType("com.google");
        String[] names = new String[accArray.length];
        for (int i = 0; i < names.length; i++) {
            names[i] = accArray[i].name;
        }
    return names;
}

因此​​,如果数组为0,你可以弹出一个对话框,要求移动到帐户设置。

So if the array is 0 you can pop-up a dialog asking to move to the account settings.

如果没有一个帐户,如果您尝试注册你对你的logcat消息错误ACCOUNT_MISSING应该看到。

Without an account if you try to register you should see on your logcat a message error ACCOUNT_MISSING.

这篇关于android系统中低于4.1谷歌云消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆