Android C2DM LAST_REGISTRATION_CHANGE?

发布于 2024-12-10 05:26:58 字数 260 浏览 0 评论 0原文

我在编写使用 C2DM 服务的应用程序时遇到问题。一切正常,但我担心注册 ID 可能会更改,当我将其发送到我的服务器时,我想发送一个好的注册 ID。 当用户登录时,我发送请求并获取注册 ID。在用户登录之前,C2DM 必须工作。但我实际上可以检查注册 ID 是否已更新,以便我可以再次将其发送到服务器吗?我知道有类似 LAST_REGISTRATION_CHANGE 的内容,但仅此而已...有关如何将当前注册 ID 与上一个注册 ID(或类似内容)进行比较的任何想法吗?谢谢!

I have a problem writing an application which uses C2DM service. Everything works OK, but I'm worried that the registration id may change and as I send it to my server, I want to send a good registration id.
When user logs in, I send a request and get a registration id. Until user is logged in, C2DM must work. But can I actually check if the registration id was updated, so I can send it to the server again? I know there is something like LAST_REGISTRATION_CHANGE, but that's all... Any ideas on how to compare current registration id with a last one (or something like that)? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半世晨晓 2024-12-17 05:26:58

所以最后你的问题得到了解决:我附上接收器的一部分代码以供其他人帮助。

*

public class C2DMReceiver extends BroadcastReceiver {
        private Context context;
        private String key;
        private String textExpand;
        private String text;
        private boolean flag = false;

        @Override
        public void onReceive(Context context, Intent intent) {
            this.context = context;
            Log.e("TAG", "Action : " + intent.getAction());
            Set<String> set = intent.getExtras().keySet();

            Iterator<String> iterator = set.iterator();
            while (iterator.hasNext()) {
                key = iterator.next();
                Log.v("TAG", key + " : " + intent.getStringExtra(key));
    }

}
}

*

So finally your problem is solved : I am enclosing a portion of code of receiver for others help.

*

public class C2DMReceiver extends BroadcastReceiver {
        private Context context;
        private String key;
        private String textExpand;
        private String text;
        private boolean flag = false;

        @Override
        public void onReceive(Context context, Intent intent) {
            this.context = context;
            Log.e("TAG", "Action : " + intent.getAction());
            Set<String> set = intent.getExtras().keySet();

            Iterator<String> iterator = set.iterator();
            while (iterator.hasNext()) {
                key = iterator.next();
                Log.v("TAG", key + " : " + intent.getStringExtra(key));
    }

}
}

*

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文