List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:com.artech.android.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 w w .j av a2 s. 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)) { //sendNotification("Send error: " + extras.toString()); Services.Log.Error(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { //sendNotification("Deleted messages on server: " + extras.toString()); Services.Log.Error(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: " + extras.toString()); // Process the real message onMessageReceive(intent); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:uk.org.downiesoft.slideshow.SlideShowActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window win = getWindow();//w w w .j av a2 s . c o m win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); win.requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); mUiHider = new UiHider(this); getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(mUiHider); mCacheManager = ThumbnailCacheManager.getInstance(this); SlideShowActivity.debug(1, TAG, "onCreate: %s", savedInstanceState == null ? "null" : savedInstanceState.toString()); setContentView(R.layout.activity_slide_show); PreferenceManager.setDefaultValues(this, R.xml.view_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.slideshow_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.cache_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.wallpaper_preferences, false); PreferenceManager.setDefaultValues(this, R.xml.other_preferences, false); mSlideshowSettings = PreferenceManager.getDefaultSharedPreferences(this); int thumbSize = Integer.parseInt(mSlideshowSettings.getString(getString(R.string.PREFS_THUMBSIZE), "1")); // Hack to convert old hard-coded thumbsize settings to platform dependent sizes if (thumbSize > 2) { thumbSize = thumbSize / 90; SharedPreferences.Editor editor = mSlideshowSettings.edit(); editor.putString(getString(R.string.PREFS_THUMBSIZE), Integer.toString(thumbSize)); editor.apply(); } FragmentManager fm = getFragmentManager(); int cacheLimit = Integer .parseInt(mSlideshowSettings.getString(getString(R.string.PREFS_CACHE_LIMIT), "10")); mPreviewButton = (ImageView) findViewById(R.id.slideShowImageButton); mPreviewView = (FrameLayout) findViewById(R.id.previewContainer); RelativeLayout divider = (RelativeLayout) findViewById(R.id.frameDivider); if (divider != null) { divider.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { return mGestureDetector.onTouchEvent(event) || view.onTouchEvent(event); } }); } mPreviewFragment = (PreviewFragment) fm.findFragmentByTag(PreviewFragment.TAG); if (mPreviewView != null && mPreviewFragment == null) { mPreviewFragment = new PreviewFragment(); fm.beginTransaction().replace(R.id.previewContainer, mPreviewFragment, PreviewFragment.TAG).commit(); } mGridViewFragment = (GridViewFragment) fm.findFragmentByTag(GridViewFragment.TAG); if (mGridViewFragment == null) { mGridViewFragment = new GridViewFragment(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.fragmentContainer, mGridViewFragment, GridViewFragment.TAG); ft.commit(); } mGestureDetector = new GestureDetector(this, new DividerGestureListener()); // restart/stop service as required Intent intent = getIntent(); if (intent != null && intent.getAction() != null && intent.getAction().equals(ACTION_STOP_WALLPAPER) && isServiceRunning()) { stopWallpaperService(); finish(); } else { if (!mSlideshowSettings.getBoolean(getString(R.string.PREFS_WALLPAPER_ENABLE), false)) { if (isServiceRunning()) { stopWallpaperService(); } } else { if (!isServiceRunning()) { Intent startIntent = new Intent(SlideShowActivity.this, WallpaperService.class); startService(startIntent); invalidateOptionsMenu(); } } } mCacheManager.tidyCache(cacheLimit); BitmapManager.setDisplayMetrics(getResources().getDisplayMetrics()); }
From source file:com.example.shivadeviah.enhancedgooglemaps.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 . ja v a 2 s .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. */ String title, message, data, username; title = extras.getString("gcm.notification.title"); message = extras.getString("gcm.notification.body"); data = extras.getString("message"); username = extras.getString("name"); 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)) { // This loop represents the service doing some work. /*for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } }*/ /* Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message.*/ GroupTripChatWindowActivity.messages.add("+:" + username + ":" + data); sendNotification(title, message); /* Log.i(TAG, "Received: " + extras.toString());*/ } } // Release the wake lock provided by the WakefulBroadcastReceiver. com.example.shivadeviah.enhancedgooglemaps.GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.app.chasebank.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 . j av a 2 s .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)) { //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)) { Log.i(TAG, extras.toString()); String alert = extras.getString("data"); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.mch.registry.ccs.app.GcmIntentService.java
@Override ///New: Mueller//from w ww. java 2 s.c o m protected void onHandleIntent(Intent intent) { mSenderId = Constants.PROJECT_ID; GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // action handling for actions of the activity String action = intent.getAction(); Log.v("PregnancyGuide", "action: " + action); if (action.equals(Constants.ACTION_REGISTER)) { register(gcm, intent); } else if (action.equals(Constants.ACTION_UNREGISTER)) { unregister(gcm, intent); } else if (action.equals(Constants.ACTION_ECHO)) { sendMessage(gcm, intent); } // handling of stuff as described on // http://developer.android.com/google/gcm/client.html try { Bundle extras = intent.getExtras(); // The getMessageType() intent parameter must be the intent you // received in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (extras != null && !extras.isEmpty()) { // has effect of unparcelling Bundle /* * 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)) { sendPhoneActivityNotification("Send error: " + extras.toString(), "Error"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendPhoneActivityNotification("Deleted messages on server: " + extras.toString(), "Deleted"); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. String msg = extras.getString("message"); PregnancyDataHandler pdh = new PregnancyDataHandler(getApplicationContext(), "fn received", null, 1); Pregnancy preg = pdh.getPregnancy(); if (TextUtils.isEmpty(msg)) { } else if (msg.contains("_R: ")) { final String recommendationMessage = msg.replaceAll("_R: ", ""); Handler mHandler = new Handler(getMainLooper()); mHandler.post(new Runnable() { @Override public void run() { RecommendationDataHandler rdh = new RecommendationDataHandler( getApplicationContext(), "Msg received", null, 1); Calendar cal = Calendar.getInstance(); rdh.addRecommendation(recommendationMessage, Utils.getPregnancyDay(getApplicationContext()), cal.getTime(), Utils.getPregnancyWeek(getApplicationContext())); sendNotification(getString(R.string.notification_text_new_recommendation), getString(R.string.app_name)); } }); } else if (msg.contains("_V: ")) { final String visitMessage = msg.replaceAll("_V: ", ""); Handler mHandler = new Handler(getMainLooper()); mHandler.post(new Runnable() { @Override public void run() { VisitDataHandler vdh = new VisitDataHandler(getApplicationContext(), "Msg received", null, 1); vdh.addVisit(visitMessage); sendNotification(getString(R.string.notification_text_new_visit), getString(R.string.app_name)); } }); } else if (msg.contains("_Verified")) { Handler mHandler = new Handler(getMainLooper()); mHandler.post(new Runnable() { @Override public void run() { PregnancyDataHandler pdh = new PregnancyDataHandler(getApplicationContext(), "Msg received", null, 1); Toast.makeText(getApplicationContext(), getString(R.string.application_ready), Toast.LENGTH_LONG).show(); pdh.setVerified(true); pdh.setLoadingProgress(pdh.getPregnancy().get_loadingProgress() + 1); } }); } else if (msg.contains("_NotVerified")) { Handler mHandler = new Handler(getMainLooper()); mHandler.post(new Runnable() { @Override public void run() { PregnancyDataHandler pdh = new PregnancyDataHandler(getApplicationContext(), "not verified", null, 1); pdh.setVerified(false); Toast.makeText(getApplicationContext(), getString(R.string.number_not_verified), Toast.LENGTH_SHORT).show(); } }); } else if (msg.contains("_PregnancyNotFound")) { Handler mHandler = new Handler(getMainLooper()); mHandler.post(new Runnable() { @Override public void run() { PregnancyDataHandler pdh = new PregnancyDataHandler(getApplicationContext(), "Msg received", null, 1); pdh.setVerified(false); Toast.makeText(getApplicationContext(), getString(R.string.number_not_found), Toast.LENGTH_LONG).show(); } }); } else if (msg.contains("_PregnancyInfosFacilityName")) { String pInfoFN = msg.replaceAll("_PregnancyInfosFacilityName: ", ""); pdh.updateFacilityName(pInfoFN); pdh.setLoadingProgress(preg.get_loadingProgress() + 1); } else if (msg.contains("_PregnancyInfosFacilityPhone")) { String pInfoFP = msg.replaceAll("_PregnancyInfosFacilityPhone: ", ""); pdh.updateFacilityPhone(pInfoFP); pdh.setLoadingProgress(preg.get_loadingProgress() + 1); } else if (msg.contains("_PregnancyInfosExpectedDelivery")) { String pInfoED = msg.replaceAll("_PregnancyInfosExpectedDelivery: ", ""); pdh.updateExpectedDelivery(pInfoED); pdh.setLoadingProgress(preg.get_loadingProgress() + 1); } else if (msg.contains("_PregnancyInfosPatientName")) { String pInfoPN = msg.replaceAll("_PregnancyInfosPatientName: ", ""); pdh.updatePatientName(pInfoPN); pdh.setLoadingProgress(preg.get_loadingProgress() + 1); } Log.i("PregnancyGuide", "Received: " + extras.toString()); } } } finally { // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:com.brq.wallet.lt.notification.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); try {// w ww . ja v a2s . com if (extras == null) { Log.i(TAG, "empty message received, ignoring"); return; } 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 /* * 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.i(TAG, "SEND ERROR: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.i(TAG, "DELETED: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.i(TAG, "Received: " + extras.toString()); if (LtApi.TRADE_ACTIVITY_NOTIFICATION_KEY.equals(extras.getString("collapse_key"))) { handleTradeActivityNotification(extras); } else if (LtApi.AD_ACTIVITY_NOTIFICATION_KEY.equals(extras.getString("collapse_key"))) { handleAdActivityNotification(extras); } } } } finally { // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:uk.org.downiesoft.slideshow.GridViewFragment.java
/** * {@inheritDoc}//from ww w . j a v a 2 s . c om */ @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("currentFile", mCurrentFile.getPath()); outState.putString("previousFile", mPreviousFile.getPath()); outState.putInt("currentImage", mCurrentImage); outState.putBoolean("showingFavourites", mShowingFavourites); SlideShowActivity.debug(1, TAG, "onSaveInstanceState: %s", outState.toString()); }
From source file:fr.neamar.notiflow.GcmIntentService.java
private void sendNotification(String flow, String msg, Bundle extras) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Boolean notifyOwnMessages = prefs.getBoolean("prefNotifyOwnMessages", false); Boolean isOwnMessage = extras.getString("own", "false").equals("true"); String notifyType = prefs.getString("prefNotifyType", "all"); // all | mentions | private Boolean isMentioned = extras.getString("mentioned", "false").equals("true"); Boolean isPrivate = extras.getString("private", "false").equals("true"); Log.d(TAG, "New message, type " + notifyType + ", mentioned: " + isMentioned + ", private: " + isPrivate); if (isOwnMessage && !notifyOwnMessages) { Log.i(TAG, "Canceling notification (user sent): " + extras.toString()); mNotificationManager.cancel(extras.getString("flow"), 0); NotificationHelper.cleanNotifications(getApplicationContext(), extras.getString("flow")); return;/* w w w . ja v a 2 s. c o m*/ } else if (notifyType.equals("mentions") && !isMentioned && !isPrivate) { Log.i(TAG, "Skipping message (not mentioned): " + extras.toString()); return; } else if (notifyType.equals("private") && !isPrivate) { Log.i(TAG, "Skipping message (not private): " + extras.toString()); return; } Date lastNotification = NotificationHelper.getLastNotificationDate(getApplicationContext(), flow); NotificationHelper.addNotification(getApplicationContext(), flow, msg); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); Boolean silentMode = prefs.getBoolean("prefNotifySilent", false); if (!silentMode) { Date now = new Date(); Long timeSinceLastNotification = now.getTime() - lastNotification.getTime(); Integer frequency = Integer.parseInt(prefs.getString("prefNotifyVibrationFrequency", "15")) * 1000; Boolean notifyWhenActive = prefs.getBoolean("prefNotifyWhenActive", false); Boolean isActive = extras.getString("active", "false").equals("true"); if (timeSinceLastNotification < frequency) { Log.i(TAG, "Skipping vibration -- cooldown in effect"); } else if (isActive && !notifyWhenActive) { Log.i(TAG, "Skipping vibration -- user already active"); } else { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS); } } ArrayList<String> prevMessages = NotificationHelper.getNotifications(getApplicationContext(), flow); Integer pendingCount = prevMessages.size(); if (pendingCount == 1) { // Only one notification : display using BigTextStyle for multiline. NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle() .bigText(Html.fromHtml(msg)); mBuilder.setStyle(style); } else { // More than one notification: use inbox style, displaying up to 5 messages NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); for (int i = 0; i < Math.min(pendingCount, 5); i++) { style.addLine(Html.fromHtml(prevMessages.get(i))); } mBuilder.setStyle(style).setContentInfo(Integer.toString(pendingCount)).setNumber(pendingCount); NotificationCompat.BigTextStyle pageStyle = new NotificationCompat.BigTextStyle(); StringBuilder pageText = new StringBuilder(); // And then add a second page for Wearables, displaying the whole pending conversation for (int i = pendingCount - 1; i >= 0; i--) { if (i < pendingCount - 1) { pageText.append("<br /><br />"); } pageText.append(prevMessages.get(i)); } pageStyle.bigText(Html.fromHtml(pageText.toString())); Notification secondPage = new NotificationCompat.Builder(this).setStyle(pageStyle) .extend(new NotificationCompat.WearableExtender().setStartScrollBottom(true)).build(); wearableExtender.addPage(secondPage); } // Set large icon, which gets used for wearable background as well String avatar = extras.getString("avatar", ""); if (!avatar.equals("")) { String sizeExpr = "(/\\d+/?)$"; Boolean isCloudFront = avatar.contains("cloudfront"); Boolean hasSize = avatar.matches(".*" + sizeExpr); if (isCloudFront) { if (!hasSize) { avatar += "/400"; } else { avatar.replaceFirst(sizeExpr, "/400"); } } ImageLoader imageLoader = ImageLoader.getInstance(); Bitmap image = imageLoader.loadImageSync(avatar); // scale for notification tray int height = (int) getResources().getDimension(android.R.dimen.notification_large_icon_height); int width = (int) getResources().getDimension(android.R.dimen.notification_large_icon_width); Bitmap scaledImage = Bitmap.createScaledBitmap(image, width, height, false); mBuilder.setLargeIcon(scaledImage); wearableExtender.setBackground(image); } // Increase priority only for mentions and 1-1 conversations if (isMentioned || isPrivate) { mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH); } // Retrieve color // Default to 0x7BD3FB int color = Integer.parseInt(extras.getString("color", "8115195")); Notification notification = mBuilder.setSmallIcon(R.drawable.notification).setColor(color) .setContentTitle(flow).setContentText(Html.fromHtml(msg)).setAutoCancel(true) .setContentIntent(createClickedIntent(flow, extras)).setDeleteIntent(createDismissedIntent(flow)) .setTicker(Html.fromHtml(msg)).setCategory(Notification.CATEGORY_SOCIAL).extend(wearableExtender) .build(); mNotificationManager.notify(flow, 0, notification); Log.i(TAG, "Displaying message: " + extras.toString()); }
From source file:br.com.awa.mylottery.gcm.MyGcmListenerService.java
/** * Called when message is received./* ww w . jav a 2 s .co 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(). */ // [START receive_message] @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 { //JSONObject jsonObject = new JSONObject(data.getString(EXTRA_DATA)); //String weather = data.getString(EXTRA_WEATHER); String message = data.getString(EXTRA_MESSAGE); String alert = String.format(message); sendNotification(alert); //} catch (JSONException e) { // JSON parsing failed, so we just let this message go, since GCM is not one // of our critical features. //} } Log.i(TAG, "Received: " + data.toString()); } }
From source file:com.nanodegree.gemma.sunshine.app.gcm.MyGcmListenerService.java
/** * Called when message is received./*from w w w . j a v 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) { // Time to 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(); } // 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 { JSONObject jsonObject = new JSONObject(data.getString(EXTRA_DATA)); 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) { // JSON parsing failed, so we just let this message go, since GCM is not one // of our critical features. } } Log.i(TAG, "Received: " + data.toString()); } }