code: public static boolean isRegisteredOnServer(Context context) {
          final SharedPreferences prefs = getGCMPreferences(context);
          boolean isRegistered = prefs.getBoolean(PROPERTY_ON_SERVER, false);
          Log.v(TAG, "Is registered on server: " + isRegistered);
          if (isRegistered) {
              // checks if the information is not stale
              long expirationTime =
                      prefs.getLong(PROPERTY_ON_SERVER_EXPIRATION_TIME, -1);
              if (System.currentTimeMillis() > expirationTime) {
                  Log.v(TAG, "flag expired on: " + new Timestamp(expirationTime));
                  return false;
              }
          }
          return isRegistered;
      }
docs: Checks whether the device was successfully registered in the server side,
  as set by {@link #setRegisteredOnServer(Context, boolean)}.
  
  <p>To avoid the scenario where the device sends the registration to the
  server but the server loses it, this flag has an expiration date, which
  is {@link #DEFAULT_ON_SERVER_LIFESPAN_MS} by default (but can be changed
  by {@link #setRegisterOnServerLifespan(Context, long)}).