Android的GCM:GCMRegistrar给空注册IDGCM、Android、ID、GCMRegistrar

2023-09-13 23:53:06 作者:老衲戒女神i

我跟 http://developer.android.com /guide/google/gcm/gs.html#server-app 的在我的应用程序中实现GCM

I have followed http://developer.android.com/guide/google/gcm/gs.html#server-app to implement GCM in my application

                    GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
        if (GCMRegistrar.isRegistered(this)) {
            Log.d(TAG, GCMRegistrar.getRegistrationId(this));
        }
        final String regId = GCMRegistrar.getRegistrationId(this);

        if (regId.equals("")) {
            GCMRegistrar.register(this, sender_id);
            Log.d(TAG, "Registration id :  "+GCMRegistrar.getRegistrationId(this));
        }
            else {
            Log.d("info", "already registered as" + regId);
        }

这是返回空字符串作为注册ID 还有什么是需要得到注册ID ??

that returns empty string as registration ID what else is needed to get the registration ID??

推荐答案

创建使用谷歌控制台具有相同名称的新项目作为Eclipse应用程序的名字帮我解决这个问题。

Creating a new project using google console with the same name as application's name in eclipse helped me to solve this problem.