我正在尝试使用以下代码将设备注册到GCM:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(this);
// the following function can be removed when deploying the app
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
GCMRegistrar.register(this, SENDER_ID);
} else {
Log.v(TAG, "Already registered");
}
Run Code Online (Sandbox Code Playgroud)
我已导入导入com.google.android.gcm.GCMRegistrar;
并将GCM.jar添加到我在Eclipse中的buildpath中,我通过sdk下载获得了
请帮忙 !