Зарегистрируйте приложение для Android в C2DM - PullRequest
1 голос
/ 21 сентября 2010

Я использую эмулятор версии 8. и когда я пытаюсь зарегистрировать приложение для Android, оно дает нулевой регистрационный идентификатор.Пожалуйста, помогите мне решить эту проблему.Как я могу зарегистрировать приложение Android с C2DM. Мой код - зарегистрировать приложение.

Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(startCode.this, 0, new Intent(), 0)); // boilerplate
registrationIntent.putExtra("sender", "12786@gmail.com");
startService(registrationIntent); 
handleRegistration(getApplicationContext(), registrationIntent);


private void handleRegistration(Context context, Intent intent) {
        String registration = intent.getStringExtra("registration_id"); 
        if (intent.getStringExtra("error") != null) {
            // Registration failed, should try again later.
            Log.e("ERROR", "ERROR");
        } else if (intent.getStringExtra("unregistered") != null) {
            // unregistration done, new messages from the authorized sender will be rejected
            Log.e("unregistered", "unregistered");
        } else if (registration != null) {
           // Send the registration ID to the 3rd party site that is sending the messages.
           // This should be done in a separate thread.
           // When done, remember that all registration is done. 
            Log.e("registration", registration);
        }
    }

1 Ответ

1 голос
/ 27 сентября 2010

Исходя из моего опыта, вам нужно добавить учетную запись Google в ваш эмулятор.

Вы можете сделать это только с целью API Google 8, но не с Android 2.2.

...