本文整理汇总了Java中com.google.android.gcm.GCMRegistrar.checkManifest方法的典型用法代码示例。如果您正苦于以下问题:Java GCMRegistrar.checkManifest方法的具体用法?Java GCMRegistrar.checkManifest怎么用?Java GCMRegistrar.checkManifest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gcm.GCMRegistrar
的用法示例。
在下文中一共展示了GCMRegistrar.checkManifest方法的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();
}
示例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();
}
}
示例3: 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());
}
}
示例4: onCreate
import com.google.android.gcm.GCMRegistrar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) { // if regId not present get one.
GCMRegistrar.register(this, "SENDER_ID");
} else { //regID already present just send a request to server to get back a notification.
HttpRequest request = new HttpRequest("POST"); //GET OR POST
request.setAction("GcmTesting");
request.setContext(getApplicationContext());
request.setGCMID(regId);
request.LoadResources(); //never forget to call this after params are set.
request.ExecuteRequest(); //this function returns a string which you echoed on the server.
//You can catch it if you want.
}
}
示例5: 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
示例6: 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 + "...");
}
示例7: 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();
}
}
示例8: 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);
}
示例9: 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);
}
}
示例10: 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);
}
}
示例11: 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();
}
}
}
示例12: 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);
}
}
示例13: 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;
}
示例14: register
import com.google.android.gcm.GCMRegistrar; //导入方法依赖的package包/类
public static int register(Context context) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if(Preferences.isNotificationsEnabled(context, preferences)) {
//GCMRegistrar.unregister(context);
try {
GCMRegistrar.checkDevice(context);
if(Studentportal.isDebugBuild()) { // the published app manifest doesn't need to be checked
GCMRegistrar.checkManifest(context);
}
String regId = GCMRegistrar.getRegistrationId(context);
if (regId.equals("")) {
GCMRegistrar.register(context, SENDER_ID);
return REGISTERING_TRIGGERED;
} else {
Log.v(TAG, "Already registered");
return ALREADY_REGISTERED;
}
} catch (UnsupportedOperationException e) {
Log.i(TAG, "this device doesn't support cloud messaging");
Toast.makeText(context, R.string.error_notification_not_supported, Toast.LENGTH_SHORT).show();
Preferences.setNotificationsEnabled(context, preferences, false);
GCMStatusBroadcastCommunicator.sendBroadcast(context,
new Intent().putExtra(GCMStatusBroadcastCommunicator.EXTRA_GCM_UP, false));
return UNSUPPORTED;
}
} else {
return DISABLED;
}
}
示例15: validateGCMSetup
import com.google.android.gcm.GCMRegistrar; //导入方法依赖的package包/类
private void validateGCMSetup()
{
int i = Build.VERSION.SDK_INT;
if (i < 8)
{
this.badGCMSetupMsg = ("Your device does not support GCM. GCM is available for Android 2.2+ (API level 8+). Your device API level is: " + i);
this.isGCMSetupValid = false;
}
try
{
GCMRegistrar.checkDevice(this.cordova.getActivity());
}
catch (UnsupportedOperationException localUnsupportedOperationException)
{
try
{
while (true)
{
GCMRegistrar.checkManifest(this.cordova.getActivity());
return;
localUnsupportedOperationException = localUnsupportedOperationException;
this.badGCMSetupMsg = ("Your device does not support GCM. " + localUnsupportedOperationException.getMessage() + ". If you are using an android emulator make sure it has Google APIs (Google Inc).");
this.isGCMSetupValid = false;
}
}
catch (IllegalStateException localIllegalStateException)
{
this.badGCMSetupMsg = ("Your application manifest is not properly set up for GCM. " + localIllegalStateException.getMessage() + ". Refer to the Google Android documentation for instructons how to setup up your application manifest for using GCM.");
this.isGCMSetupValid = false;
}
}
}