Although I try other answer about this problem, it can’t be solved.
Sender ID is correct, permissions are added, API key is true.
I use this post for creating the project:
http://developer.android.com/guide/google/gcm/gs.html#server-app
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
GCMRegistrar.register(this, SENDER_ID);
regId = GCMRegistrar.getRegistrationId(this);
} else {
Log.v(TAG, "Already registered");
}
String did = getDeviceID();
it returns empty string.
Do you have
GCMIntentServicedefined correctly at the root package of your app?Make sure that
"my_app_package"is identical to the main package of your app, or your id will return an empty string.Also notice that
is asynchronous. Therefore, calling
GCMRegistrar.getRegistrationId(this)immediately after that is not reliable, so you should avoid it.The id will arrive via broadcast callback to your
GCMIntentService, as a part of the registration procedure. from there you can then store the gcm/fcm key anywhere you like, and use it in other parts of the application (usually on the server).