List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:com.aylanetworks.aura.GcmIntentService.java
@SuppressWarnings("unchecked") @Override/* w ww.j a v a 2s . c o m*/ 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 /* * 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(), null); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), null); // 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. //PushNotification.playSound("Beep_once.ogg"); for (int i = 0; i < 3; i++) { Log.i(TAG, "Working... " + (i + 1) + "/3 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(500); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. String message = extras.getString("message"); String sound = extras.getString("sound"); //String other = extras.getString("other"); sendNotification(message, sound); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.example.demoflavius.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String message = intent.getExtras().getString("message"); // 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()); } 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)) { // Post notification of received message. sendNotification(message); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:net.stefanopallicca.android.awsmonitor.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); Log.i(TAG + ":onMessage extras ", extras.getString("body")); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w w w . j av a 2 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)) { // 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. String messageBody = extras.getString("body"); //sendNotification("Received: " + extras.toString()); NotificationsDatasource nd = new NotificationsDatasource(getApplicationContext()); nd.open(); //String messageBody = (String) intent.getExtras().getCharSequence("body"); nd.dbAddNotification(messageBody); // Invia messaggio sendNotification(messageBody); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.example.android.sunshine.app.gcm.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Is this our message?? Better be if you're going to act on it! if (MainActivity.PROJECT_NUMBER.equals(extras.getString(EXTRA_SENDER))) { // Process message and then post a notification of the received message. String weather = extras.getString(EXTRA_WEATHER); String location = extras.getString(EXTRA_LOCATION); String alert = "Heads up: " + weather + " in " + location + "!"; sendNotification(context, alert); }/*from ww w . j a v a 2 s . c o m*/ Log.i(LOG_TAG, "Received: " + extras.toString()); } } }
From source file:org.openchaos.android.buildmessage.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 . j a va 2 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)) { Log.w(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.w(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()); String sender = extras.getString("from"); int senderIndex = 0; // TODO: multiple senders in a string set if (!((sender != null) && sender.equals(prefs.getString("sender_id_1", null)))) { Log.w(TAG, "Unknown GCM sender: " + sender); // return; } createNotification(senderIndex, extras.getString("m"), extras.getString("i")); } else { Log.d(TAG, "Unknown GCM message type. Message ignored: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.rampgreen.caretakermobile.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 www . jav a 2 s . 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)) { sendNotification("Error", "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted Messages", "Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { GcmMsgBean gcmMsgBean = null; String msg = null; try { msg = extras.getString("message"); JSONObject jsonObject = new JSONObject(msg); gcmMsgBean = new GcmMsgBean(); gcmMsgBean.parseGcmMsg(jsonObject); } catch (JSONException e) { AppLog.printStackTrace(e); } if (gcmMsgBean == null || msg == null) { return; } String title = gcmMsgBean.getNotificationTitle(); String subtitle = gcmMsgBean.getNotificationSubTitle(); msg = title + ":" + subtitle; String msgList = (String) AppSettings.getPrefernce(this, null, AppSettings.STORE_NOTI_LIST, ""); if (StringUtils.isEmpty(msgList)) { msgList = msg; } else { msgList = msgList + "|" + msg; } AppSettings.setPreference(this, null, AppSettings.STORE_NOTI_LIST, msgList); sendNotification(gcmMsgBean.getNotificationTitle(), gcmMsgBean.getNotificationSubTitle()); AppLog.d(TAG, "Received: " + extras.toString()); } // 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. // } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.measurence.sdk.android.gcm_push_notifications.PresenceSessionUpdatesNotificationService.java
@Override protected void onHandleIntent(Intent intent) { try {//from w ww. j a v a 2 s . c o m 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 /* * 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(LOG_TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.i(LOG_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)) { String presenceSessionUpdateJson = extras.getString("user-session"); Log.i(LOG_TAG, "received|json|" + presenceSessionUpdateJson); notifySessionUpdateToUI(presenceSessionUpdateJson); } } } finally { // Release the wake lock provided by the WakefulBroadcastReceiver. // The device is no longer prevented from sleeping GcmPushNotificationsReceiver.completeWakefulIntent(intent); } }
From source file:com.winginno.charitynow.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Log.i(TAG, "GcmIntentService.onHandleIntent"); 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 ww w . ja v a2 s . 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)) { // sendNotification("Send error: " + extras.toString()); Log.i(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { // sendNotification("Deleted messages on server: " + extras.toString()); Log.i(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)) { // 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. SettingsStorage settingsStorage = new SettingsStorage(); Settings settings = settingsStorage.get(); if (settings.isOtherNotiEnabled()) { sendNotification(extras); } Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.procialize.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { System.out.println("Inside OnHandle Intent"); sendNotification("Received: "); Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. // GCM Message TYpe // String messageType = gcm.getMessageType(intent); String messageType = "gcm"; if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*// w ww .j a v a2 s . 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)) { 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. sendNotification("Received: " + extras.toString()); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.example.week04.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 . j a va 2s . 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)) { // TODO :: check wifi-stat // Receive articles, and post notification of received message. String keyword = extras.getString("new data"); getArticleInBackground(keyword); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }