Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向C2DM注册Android应用程序_Android_Push Notification_Android C2dm - Fatal编程技术网

向C2DM注册Android应用程序

向C2DM注册Android应用程序,android,push-notification,android-c2dm,Android,Push Notification,Android C2dm,我正在使用版本8的模拟器。当我尝试注册Android应用程序时,它会给出空的注册ID。请帮助我解决这个问题。如何在C2DM中注册Android应用程序。我的代码是注册应用程序 Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER"); registrationIntent.putExtra("app", PendingIntent.getBroadcast(startCode.this, 0

我正在使用版本8的模拟器。当我尝试注册Android应用程序时,它会给出空的注册ID。请帮助我解决这个问题。如何在C2DM中注册Android应用程序。我的代码是注册应用程序

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);
        }
    }

根据我的经验,您需要在模拟器中添加一个google帐户


您只能使用Google API 8的目标,而不是Android 2.2。根据我的经验,您需要在模拟器中添加一个Google帐户


您只能使用Google API 8的目标,而不是Android 2.2。

我正在使用Google API 8,并且我已经在模拟器中创建了帐户,但如何将通知发送到模拟器?注册过程完全自动化,在模拟器中运行良好。如前所述,您需要设置一个Google帐户,但是您的注册代码应该会产生一个注册响应(以及一个C2DM ID)。如果您没有找回ID,那么您就丢失了其他内容(可能是权限?请检查logcat)。“通过C2DM通道向仿真器发送通知”仍然需要Google服务器才能工作。没有“模拟”C2DM消息选项,您必须使用此处概述的说明通过Google服务器发送一条消息:我正在使用Google API 8,并且我已经在emulator中创建了帐户,但如何将通知发送到我的emulator注册过程完全自动化,在emulator中运行良好。如前所述,您需要设置一个Google帐户,但是您的注册代码应该会产生一个注册响应(以及一个C2DM ID)。如果您没有找回ID,那么您就丢失了其他内容(可能是权限?请检查logcat)。“通过C2DM通道向仿真器发送通知”仍然需要Google服务器才能工作。没有“模拟”C2DM消息选项,您必须使用此处概述的说明通过Google服务器发送一条消息: