lomza
lomza

Reputation: 9716

Android C2DM LAST_REGISTRATION_CHANGE ?

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!

Upvotes: 0

Views: 128

Answers (1)

Arpit Garg
Arpit Garg

Reputation: 8546

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

} }

*

Upvotes: 1

Related Questions