当前位置: 首页>>代码示例>>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;未经允许,请勿转载。