C2DM注册错误

时间:2012-05-18 11:12:20

标签: android android-c2dm

我试图注册c2dm,但总是给我这个错误:

05-18 10:48:32.357:D / C2DMRegistrar(225):[C2DMRegistrar.46]注册:http错误400

这是注册方法:

public static final String EXTRA_SENDER = "sender";
public static final String EXTRA_APPLICATION_PENDING_INTENT = "app";
public static final String REQUEST_UNREGISTRATION_INTENT = "com.google.android.c2dm.intent.UNREGISTER";
public static final String REQUEST_REGISTRATION_INTENT = "com.google.android.c2dm.intent.REGISTER";
public static final String LAST_REGISTRATION_CHANGE = "last_registration_change";
public static final String BACKOFF = "backoff";
// public static final String GSF_PACKAGE = "com.google.android.gsf";

public static void register(Context context, String senderId) {
Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
// registrationIntent.setPackage(GSF_PACKAGE);
registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
    PendingIntent.getBroadcast(context, 0, new Intent(), 0));
registrationIntent.putExtra(EXTRA_SENDER, senderId);
context.startService(registrationIntent);
}

我使用GSF_PACKAGE进行测试,没有GSF_PACKAGE

SenderId是邮件帐号XXXX@XXX.com,我收到了这样的邮件:

From: noreply@google.com [mailto:noreply@google.com] 

Thank you for your interest in Android Cloud to Device Messaging (C2DM).
We've accepted your application into the trial group. The Google account
you requested as the sender account for your application:

 XXXX@XXX.com

我在AVD模拟器中,我在模拟器中也有一个谷歌帐户。而在真正的手机中,同样的事情。

我在C2DMBaseReceiver.onHandleIntent没有收到任何电话,只显示错误。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您是否已通过模拟器设置了自己的Google帐户,如果没有通过设置 - >进行设置帐户并SYNC->添加一个帐户 希望这会有所帮助!!!