當前位置: 首頁>>代碼示例>>Java>>正文


Java GCMRegistrar.checkDevice方法代碼示例

本文整理匯總了Java中com.google.android.gcm.GCMRegistrar.checkDevice方法的典型用法代碼示例。如果您正苦於以下問題:Java GCMRegistrar.checkDevice方法的具體用法?Java GCMRegistrar.checkDevice怎麽用?Java GCMRegistrar.checkDevice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gcm.GCMRegistrar的用法示例。


在下文中一共展示了GCMRegistrar.checkDevice方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_splash);
	// Thread.setDefaultUncaughtExceptionHandler(new UnCaughtException(
	// SplashActivity.this));
	mApplication = (InternalApp) getApplication();
	if (!mApplication.isTabletLayout()) {
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	}
	GCMRegistrar.checkDevice(this);
	GCMRegistrar.checkManifest(this);

	final String regId = GCMRegistrar.getRegistrationId(this);
	if (regId.equals("")) {
		// Automatically registers application on startup.
		GCMRegistrar.register(this, CommonUtilities.SENDER_ID);
	}

	initiateSkillsApi();
	hideActionbar();
	getAllReferences();
	loadControls();
	loadAnimation();
}
 
開發者ID:himanshuagarwal77225,項目名稱:BookMySkills,代碼行數:26,代碼來源:SplashActivity.java

示例2: registerGCM

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
/**
 * Registers GCM and sends to server
 */
private void registerGCM() {
    try {
        GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);
        final String regId = GCMRegistrar.getRegistrationId(this);
        if (regId.equals("")) {
            GCMRegistrar.register(this, Config.GCM_SENDER_ID);
        } else {
            if (Remember.getBoolean("gcmSent", false)) {
                ApiService.getClientJackson().register(
                    regId,
                    U.getDeviceId(this)
                ).enqueue(new Summon<Result>() {
                    @Override
                    public void onSuccess(Call<Result> call, Response<Result> response) {
                        Remember.putBoolean("gcmSent", true);
                    }
                });
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:alashow,項目名稱:datmusic-android,代碼行數:28,代碼來源:MainActivity.java

示例3: removeWpComUserRelatedData

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
public static void removeWpComUserRelatedData(Context context) {
    // cancel all Volley requests - do this before unregistering push since that uses
    // a Volley request
    VolleyUtils.cancelAllRequests(requestQueue);

    NotificationsUtils.unregisterDevicePushNotifications(context);
    try {
        GCMRegistrar.checkDevice(context);
        GCMRegistrar.unregister(context);
    } catch (Exception e) {
        AppLog.v(T.NOTIFS, "Could not unregister for GCM: " + e.getMessage());
    }

    SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
    editor.remove(WordPress.WPCOM_USERNAME_PREFERENCE);
    editor.remove(WordPress.ACCESS_TOKEN_PREFERENCE);
    editor.commit();

    // reset all reader-related prefs & data
    AppPrefs.reset();
    ReaderDatabase.reset();

    // Reset Simperium buckets (removes local data)
    SimperiumUtils.resetBucketsAndDeauthorize();
}
 
開發者ID:ldsddn,項目名稱:wordpress_app_android,代碼行數:26,代碼來源:WordPress.java

示例4: setGCM

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
/**
   * GCM
   */
  public static void setGCM(Context context) {
      //
      // GCM
      //
try {
       GCMRegistrar.checkDevice(context);
       GCMRegistrar.checkManifest(context);
       final String regId = GCMRegistrar.getRegistrationId(context);
       
       if (regId.equals("")) {
       	GCMRegistrar.register(context, Util.SENDER_ID);
       } else {
       	Util.regId = regId;
       	Util.logDebug("Already registered - imei: " + Util.imei + " gcm: " + regId);

       	Util.registradoGCM = true; // marcar como registrado para no intentarlo m�s

       	registerOnLocalServer(context); // lo hago otra vez para asegurar
       }
      
} catch (Exception e) {
	Util.logDebug("Exception setGCM: " + e.getMessage());
}
  	
  }
 
開發者ID:pacosal,項目名稱:ownmdm,代碼行數:29,代碼來源:Util.java

示例5: gcmUnregister

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
public void gcmUnregister() {
    GCMRegistrar.checkDevice(context);
    GCMRegistrar.unregister(context);

    new UnRegisterGcmTask(context, new ServiceCallback<String>() {
        @Override
        public void onSuccess(String response) {
            Log.d(TAG, "Successfully unregistered push");
        }

        @Override
        public void onFailure(String reason) {
            Log.e(TAG, "Could not unregister push");
        }
    });
}
 
開發者ID:MinHalsoplan,項目名稱:netcare-healthplan,代碼行數:17,代碼來源:GCMHelper.java

示例6: gcmRegistration

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
private void gcmRegistration() {
	String senderId = Preferences.getSenderId(this);

    try {
		GCMRegistrar.checkDevice(this);
	    GCMRegistrar.checkManifest(this);
		final String registrationId = GCMRegistrar.getRegistrationId(this);
		if( registrationId != null && !"".equals(registrationId) ) {
			Log.d(TAG, "Already registered. registrationId is " + registrationId);
		} else {
			Log.d(TAG, "No existing registrationId. Registering.");
			GCMRegistrar.register(this, senderId);
		}
    } catch (UnsupportedOperationException e) {
        Toast.makeText(this, R.string.gcm_not_supported, Toast.LENGTH_SHORT).show();
    }
	
}
 
開發者ID:thunderace,項目名稱:newtifry,代碼行數:19,代碼來源:Newtifry.java

示例7: registerIfNeeded

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
/**
 * Register the device for GCM.
 *
 * @param app
 *          {@link Application} that will be used for registering on GCM.
 */
public static void registerIfNeeded(Application app) {

  // check if already registered
  if (GCMRegistrar.isRegistered(app)) {
    Log.i(Consts.TAG, "register: already registered: " + app);
    return;
  }

  // validate project number
  boolean hasValidProjectNumber = Consts.PROJECT_NUMBER.matches("\\d+");
  if (!hasValidProjectNumber) {
    Log.i(Consts.TAG, "register: invalid project number: " + Consts.PROJECT_NUMBER);
    return;
  }

  // register the app
  GCMRegistrar.checkDevice(app);
  GCMRegistrar.checkManifest(app);
  GCMRegistrar.register(app, Consts.PROJECT_NUMBER);
  Log.i(Consts.TAG, "register: registering GCM for " + app + "...");
}
 
開發者ID:harrypritchett,項目名稱:Give-Me-Ltc-Android-App,代碼行數:28,代碼來源:GCMIntentService.java

示例8: initializeGCM

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
/**
 * Initializes Google Cloud Messaging
 */
private void initializeGCM() {

  try {

    Context context = activity.getApplicationContext();

    GCMRegistrar.checkDevice(context);
    GCMRegistrar.checkManifest(context);

    String regId = GCMRegistrar.getRegistrationId(context);

    if (regId == null || regId.trim().length() == 0 || !GCMRegistrar.isRegistered(context)
        || !GCMRegistrar.isRegisteredOnServer(context)) {
      GCMRegistrar.register(context, GameBackendSettings.GCM_SENDER_ID);
    }
  } catch (RuntimeException e) {
    Log.e(TAG, "initializeGCM", e);
  }
}
 
開發者ID:GoogleCloudPlatform,項目名稱:solutions-griddler-sample-android-client,代碼行數:23,代碼來源:GoogleServicesFragment.java

示例9: onCreate

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // this is a hack to force AsyncTask to be initialized on main thread. Without this things
  // won't work correctly on older versions of Android (2.2, apilevel=8)
  try {
  	Class.forName("android.os.AsyncTask");
  } catch (Exception ignored) {}
  
  GCMRegistrar.checkDevice(this);
  GCMRegistrar.checkManifest(this);

  initUI();

  AppServices.loginAndRegisterForPush(this);
}
 
開發者ID:apigee,項目名稱:apigee-android-sdk,代碼行數:18,代碼來源:PushMainActivity.java

示例10: registerAtGCM

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
protected static void registerAtGCM(Context context) {
    GCMRegistrar.checkDevice(context);
    GCMRegistrar.checkManifest(context);
    
    final String regId = GCMRegistrar.getRegistrationId(context);
    if (regId.equals("")) {
        GCMRegistrar.register(context, SENDER_ID);
        Log.v(TAG, "Already registered:sdnmbg " + regId);
    } else {
        Log.v(TAG, "Already registered: " + regId);
    }
   
}
 
開發者ID:muneerulhudha,項目名稱:ThereWillBeBlood,代碼行數:14,代碼來源:GCMIntentService.java

示例11: register

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
/**
 * Register this account/device pair within the server.
 * 
 * @return whether the registration succeeded or not.
 */
public void register(final NotifierEvent notifierEvent) {
	getCurrentForegroundApp();
	this.currentEvent = CURRENT_EVENT_PUSH_REGISTER;
	// TODO register this notifier as 'SmartPushListener' so that
	// whenever a push notification is received in the 'IntentService', it
	// can forward notification to this class
	SessionData.getInstance().setNotifierPushMessageListener(this);
	initRegistrationParams(notifierEvent);
	this.currentNotifierEvent = notifierEvent;
	checkNotNull(SENDER_ID, "SENDER_ID");
	// Make sure the device has the proper dependencies.
	GCMRegistrar.checkDevice(context);
	// Make sure the manifest was properly set - comment out this line
	// while developing the app, then un-comment it when it's ready.
	GCMRegistrar.checkManifest(context);

	context.registerReceiver(mHandleMessageReceiver, new IntentFilter(DISPLAY_MESSAGE_ACTION));

	final String regId = GCMRegistrar.getRegistrationId(context);
	Log.d(SmartConstants.APP_NAME, "******************PushMessageNotifier->registerListener->regId:" + regId);
	if (regId.equals("")) {
		// Automatically registers application on startup.
		GCMRegistrar.register(context, SENDER_ID);
	} else {
		// Means that the device has already been registered at the GCM
		// server. Need to register it at the UPNS
		registerDeviceWithServer(regId);
	}
}
 
開發者ID:appez,項目名稱:appez-android,代碼行數:35,代碼來源:PushNotificationUtility.java

示例12: checkGCM

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
private void checkGCM() {
    // check gcm registration
    if (sp.getFromPreferences("gcm").equals("") && !sp.getFromPreferences("userid").equals("") && cd.isConnectingToInternet()) {
        try {
            // Make sure the device has the proper dependencies.
            GCMRegistrar.checkDevice(this);

            // Make sure the manifest was properly set - comment out this line
            // while developing the app, then uncomment it when it's ready.
            GCMRegistrar.checkManifest(this);

            // Get GCM registration id
            final String regId = GCMRegistrar.getRegistrationId(this);

            // Check if regid already presents
            if (regId.equals("")) {
                // Registration is not present, register now with GCM
                GCMRegistrar.register(this, Globals.SENDER_ID);
            } else
            // Try to register again if device is not registered on GCM
            {
                if (!GCMRegistrar.isRegisteredOnServer(this)) {
                    ServerUtilities.register(MainActivity.this, regId);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:maysamrasoli,項目名稱:Doctor,代碼行數:31,代碼來源:MainActivity.java

示例13: call

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
@Override
public FREObject call(FREContext context, FREObject[] args) 
{
	FREObject result;
	
	String message = "Device was not registered with GCM.";
	
	Log.i("GCMExtension", "checking device registration");
	
	GCMRegistrar.checkDevice(context.getActivity().getApplication());
	
	final String regId = GCMRegistrar.getRegistrationId(context.getActivity().getApplication());
       
	if (!regId.equals("")) 
       {
		GCMRegistrar.unregister(context.getActivity().getApplication());
		message = "GCMServer: Unregistering device from GCM server...";
       }
   
	
	try 
	{
		result = FREObject.newObject(message);
		return result;
	} 
	catch (FREWrongThreadException e) 
	{
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	return null;
}
 
開發者ID:breealyeska,項目名稱:GCMExtension,代碼行數:34,代碼來源:GCMPushUnregisterFunction.java

示例14: initializeGcmForTest

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
/**
 * Initializes GCM as a convenience method for tests. In production, applications should handle
 * this.
 */
public static void initializeGcmForTest(Context context, Logger logger, String senderId) {
  // Initialize GCM.
  GCMRegistrar.checkDevice(context);
  GCMRegistrar.checkManifest(context);
  String regId = GCMRegistrar.getRegistrationId(context);
  if (regId.isEmpty()) {
    logger.info("Not registered with GCM; registering");
    GCMRegistrar.register(context, senderId);
  } else {
    logger.fine("Already registered with GCM: %s", regId);
  }
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:17,代碼來源:AndroidMessageReceiverService.java

示例15: initializeGcm

import com.google.android.gcm.GCMRegistrar; //導入方法依賴的package包/類
/**
 * Registers with GCM if not already registered. Also verifies that the device supports GCM
 * and that the manifest is correctly configured. Returns the existing registration id, if one
 * exists, or the empty string if one does not.
 *
 * @throws UnsupportedOperationException if the device does not have all GCM dependencies
 * @throws IllegalStateException if the manifest is not correctly configured
 */
public static String initializeGcm(Context context) {
  AndroidChannelPreferences.setGcmChannelType(context, GcmChannelType.DEFAULT);
  GCMRegistrar.checkDevice(context);
  GCMRegistrar.checkManifest(context);
  final String regId = GCMRegistrar.getRegistrationId(context);
  if (regId.isEmpty()) {
    GCMRegistrar.register(context, readSenderIdsFromManifestOrDie(context));
  }
  return regId;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:19,代碼來源:MultiplexingGcmListener.java


注:本文中的com.google.android.gcm.GCMRegistrar.checkDevice方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。