Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8825547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:54:19+00:00 2026-06-14T06:54:19+00:00

I have read articles about GCM may refresh registration id with no regular cycle.

  • 0

I have read articles about GCM may refresh registration id with no regular cycle. I am trying to build an app using push notification but not so sure how to handle such refreshed registration ids.

My first strategy is requesting registration id everytime the app starts and send it to the app server. It looks working but sounds wrong somehow…

Is it ok to do like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:54:20+00:00Added an answer on June 14, 2026 at 6:54 am

    Basically, you should do the following in your main activity:

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_layout);
    
        GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
    
        final String regId = GCMRegistrar.getRegistrationId(this);
    
        if (regId.equals("")) {
            GCMRegistrar.register(this, GCMIntentService.GCM_SENDER_ID);
        } else {
            Log.v(TAG, "Already registered");
        }
    }
    

    Afterwards you should send the registration id to your app server, whenever the app receives an com.google.android.c2dm.intent.REGISTRATION intent with a registration_id extra. This could happen when Google periodically updates the app’s id.

    You can achieve this by extending com.google.android.gcm.GCMBaseIntentService with your own implementation, e.g.:

    public class GCMIntentService extends GCMBaseIntentService {
    
        // Also known as the "project id".
        public static final String GCM_SENDER_ID = "XXXXXXXXXXXXX";
    
        private static final String TAG = "GCMIntentService";
    
        public GCMIntentService() {
            super(GCM_SENDER_ID);
        }
    
        @Override
        protected void onRegistered(Context context, String regId) {
            // Send the regId to your server.
        }
    
        @Override
        protected void onUnregistered(Context context, String regId) {
            // Unregister the regId at your server.
        }
    
        @Override
        protected void onMessage(Context context, Intent msg) {
            // Handle the message.
        }
    
        @Override
        protected void onError(Context context, String errorId) {
            // Handle the error.
        }
    }
    

    For more details, I would (re)read the documentation for writing the client side code and the Advanced Section of the GCM documentation.

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read various articles about passing variables around using RMI. Some of them
I have read a couple of articles about the using statement to try and
I'm using Linq to SQL on a project and have read articles about how
I have read a couple of articles about using new JS frameworks like Backbone.js
I have read some articles about using spatial optimized tables. Actually I use stored
I have read few articles about table partioning but still I am bit confused
I have read multiple articles about why singletons are bad. I know it has
I have read a ton of articles about how to store and compare entered
I've read a number of articles about UDP packet sizes but have been unable
I am trying understand ViewModels deeper and I have read many articles and blogs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.