List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:trogdor.itemhunter.mobileapp.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); String messageType = GoogleCloudMessaging.getInstance(this).getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (extras.getString(KEY_NOTIF_TYPE).equals(TYPE_OUTBID)) { sendOutbidNotification(extras); } else if (extras.getString(KEY_NOTIF_TYPE).equals(TYPE_CUSTOM)) { displayNotification(extras.getString(KEY_CUSTOM_MSG), null); }//from w w w. ja v a2 s . co m } else if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { displayNotification("Send error: " + extras.toString(), null); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { displayNotification("Deleted messages on server: " + extras.toString(), null); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.hybris.mobile.lib.commerce.sync.CatalogSyncAdapter.java
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {//from w w w . j av a 2 s. c o m Log.i(TAG, "Receiving a sync with bundle: " + extras.toString()); // Get some optional parameters String categoryId = extras.getString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID); String productId = extras.getString(CatalogSyncConstants.SYNC_PARAM_DATA_ID); boolean loadVariants = extras.getBoolean(CatalogSyncConstants.SYNC_PARAM_LOAD_VARIANTS); String contentServiceHelperUrl = extras .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_URL); boolean cancelAllRequests = extras.getBoolean(CatalogSyncConstants.SYNC_PARAM_CANCEL_ALL_REQUESTS); // Update the content service helper url if (StringUtils.isNotBlank(contentServiceHelperUrl)) { String catalog = extras.getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG); String catalogId = extras.getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG_ID); String catalogVersionId = extras .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG_VERSION_ID); String catalogMainCategoryId = extras .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_MAIN_CATEGORY_ID); updateContentServiceHelperUrlConfiguration(contentServiceHelperUrl, catalog, catalogId, catalogVersionId, catalogMainCategoryId); } // Cancelling all the requests else if (cancelAllRequests) { cancelAllRequests(); } // Sync a category else if (StringUtils.isNotBlank(categoryId)) { Log.i(TAG, "Syncing the category " + categoryId); int currentPage = 0; int pageSize = 0; if (extras.containsKey(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE) && extras.containsKey(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE)) { currentPage = extras.getInt(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE); pageSize = extras.getInt(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE); } syncCategory(categoryId, currentPage, pageSize); } // Sync a product else if (StringUtils.isNotBlank(productId)) { Log.i(TAG, "Syncing the product " + productId); loadProduct(productId, categoryId, null, false, loadVariants); } // Sync all the catalog else { Log.i(TAG, "Syncing the catalog"); // Init nb calls counter and blocker mNbCalls = new AtomicInteger(); mBlockSync = new CountDownLatch(1); String categories = extras.getString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID_LIST); try { String[] categoryList = null; if (StringUtils.isNotBlank(categories)) { categoryList = categories.split(CatalogSyncConstants.SYNC_PARAM_GROUP_ID_LIST_SEPARATOR); } syncCatalog(categoryList); // Save the date mContentServiceHelper.saveCatalogLastSyncDate(new Date().getTime()); // Showing the notification showNotificationProgress(true); // Wait for the end of the sync mBlockSync.await(getContext().getResources().getInteger(R.integer.sync_timeout_in_min), TimeUnit.MINUTES); } catch (InterruptedException e) { Log.e(TAG, "Error syncing the catalog"); } } }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.gcm.MyGCMIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { /*/* w w w .ja v a2s.co m*/ * Filter messages based on message type. Since it is likely that * GCM will be extended in the future with new message types, just * ignore any message types you're not interested in, or that you * don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { log.warn("Gcm send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { log.warn("Gcm deleted: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { log.warn("Gcm message: " + extras.toString()); onMessage(intent); } MyGCMBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:in.udacity.learning.gcm.MyGcmListenerService.java
/** * Called when message is received.// w ww. j a v a 2s .c o m * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ @Override public void onMessageReceived(String from, Bundle data) { // Time to unparcel the bundle! if (!data.isEmpty()) { // TODO: gcm_default sender ID comes from the API console String senderId = getString(R.string.gcm_defaultSenderId); if (senderId.length() == 0) { Toast.makeText(this, "SenderID string needs to be set", Toast.LENGTH_LONG).show(); } // Not a bad idea to check that the message is coming from your server. if ((senderId).equals(from)) { // Process message and then post a notification of the received message. try { //String d = data.getString(EXTRA_DATA); String d2 = data.toString(); d2 = d2.replace("Bundle", ""); JSONArray jsonArray = new JSONArray(d2); JSONObject jsonObject = jsonArray.getJSONObject(0); String weather = jsonObject.getString(EXTRA_WEATHER); String location = jsonObject.getString(EXTRA_LOCATION); String alert = String.format(getString(R.string.gcm_weather_alert), weather, location); sendNotification(alert); } catch (JSONException e) { Log.e(TAG, e.toString()); } } Log.i(TAG, "Received: " + data.toString()); } }
From source file:com.beepscore.android.sunshine.gcm.MyGcmListenerService.java
/** * Called when message is received./* ww w.j av a 2 s. c o m*/ * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ @Override public void onMessageReceived(String from, Bundle data) { // Unparcel the bundle if (!data.isEmpty()) { String senderId = getString(R.string.gcm_defaultSenderId); if (senderId.length() == 0) { Toast.makeText(this, "SenderID string needs to be set", Toast.LENGTH_LONG).show(); } if ((senderId).equals(from)) { // this message came from our server, safe to respond to it. String weather = data.getString(EXTRA_WEATHER); String location = data.getString(EXTRA_LOCATION); String alert = String.format(getString(R.string.gcm_weather_alert), weather, location); sendNotification(alert); } Log.i(TAG, "Received: " + data.toString()); } }
From source file:org.dodgybits.shuffle.android.server.gcm.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*/*from w ww .jav a2s. c o m*/ * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Log.e(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.d(TAG, "Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.i(TAG, "Received message" + extras.toString()); Intent syncIntent = new Intent(this, SyncSchedulingService.class); syncIntent.putExtra(SOURCE_EXTRA, GCM_SOURCE); WakefulBroadcastReceiver.startWakefulService(this, syncIntent); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:coupling.app.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w w w.j a v a2s . c om * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Utils.LogError("GcmIntentService", extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Utils.LogError("GcmIntentService", "Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (extras.getString("messageId") != null) { long messageId = Long.parseLong(extras.getString("messageId")); API.getInstance().getMessage(messageId); } else { Utils.LogError("GcmIntentService", "No Message Id"); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.camera.simplewebcam.push.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w w w. ja v a 2s. com * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Log.e(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.e(TAG, "Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); Log.i(TAG, "Received: " + extras.getString("text")); Intent sendIntent = new Intent(getApplicationContext(), Main.class); sendIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, extras.getString("text")); startActivity(sendIntent); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:li.klass.fhem.activities.core.FragmentBaseActivity.java
private void switchToFragment(FragmentType fragmentType, Bundle data) { if (!saveInstanceStateCalled) { if (data == null) data = new Bundle(); Log.i(TAG, "switch to " + fragmentType.name() + " with " + data.toString()); if (fragmentType.isTopLevelFragment()) { clearBackStack();/*from w w w . j ava2 s . c o m*/ } BaseFragment contentFragment = createContentFragment(fragmentType, data); BaseFragment navigationFragment = createNavigationFragment(fragmentType, data); setContent(navigationFragment, contentFragment); } }
From source file:tmnt.wheresyourcar.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*// ww w.jav a2 s .c om * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { sendNotification(extras.get("message").toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }