List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:tm.alashow.dotjpg.android.gcm.PushNotificationsService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { U.l("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { U.l("Message is deleted"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { U.l("Normal message received! Showing notification.."); showNotification(getApplicationContext(), intent); }//from w w w . j a v a 2 s .c om } GCMReceiver.completeWakefulIntent(intent); }
From source file:com.pubkit.gcm.PubKitGcmIntentService.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()) { String message = extras.toString(); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Log.i(TAG, "Received GCM message type 'error'"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.i(TAG, "Received GCM message type 'deleted'"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.i(TAG, "Received GCM message"); }/*w w w.j a v a2 s .co m*/ sendNotification(extras.toString(), messageType); } // Release the wake lock provided by the WakefulBroadcastReceiver. PubKitGcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:au.com.websitemasters.schools.thornlie.push.MyGcmListenerService.java
/** * Called when message is received./*from w ww .ja 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(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d("rklogs", "data.toString()_" + data.toString()); Log.d("rklogs", "From: " + from); Log.d("rklogs", "Message: " + message); if (from.startsWith("/topics/")) { Log.d("rklogs", "message received from some topic."); } else { Log.d("rklogs", "normal downstream message."); } // [START_EXCLUDE] /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ try { if ((data.getString("catid").equals("9"))) { if (((SchoolsApplication) getApplicationContext()).getSetting("News") == true) { sendNotification(message, NewsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("28")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Kindy") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("29")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Pre-Primary") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("30")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Year1") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("31")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Year2") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("32")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Year3") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("33")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Year4") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("34")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Year5") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (data.getString("catid").equals("35")) { if (((SchoolsApplication) getApplicationContext()).getSetting("Year6") == true) { sendNotification(message, AlertsMenuActivity.class); } else { //do nothing } } if (((data.getString("catid").equals("22")) || (data.getString("catid").equals("23")) || (data.getString("catid").equals("24")))) { if (((SchoolsApplication) getApplicationContext()).getSetting("Newsletters") == true) { sendNotification(message, NewslettersMenuActivity.class); } else { //do nothing } } } catch (NullPointerException e) { Log.d("rklogs", "ER! Nullpointer in MyGCMListener"); } // [END_EXCLUDE] }
From source file:com.mozilla.simplepush.simplepushdemoapp.GcmIntentService.java
/** Handle the new event. * * @param intent GCM message recv'd/* w w w .j a v a 2s. c o m*/ */ @Override protected void onHandleIntent(Intent intent) { // getExtras contains the data from the remote server. Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { String msg; if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { msg = "Send error: " + extras.toString(); Log.e(TAG, msg); displayNotification(extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { msg = "Deleted messages on server: " + extras.toString(); Log.e(TAG, msg); displayNotification(extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { displayNotification(extras); msg = "Recv'd" + extras.toString(); Log.i(TAG, msg); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.fast.van.cloudmessaging.MyGcmListenerService.java
/** * Called when message is received.//from ww w .j a va 2 s . c om * * @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) { String result = null; String message = null; String orderId = null; String notificationType = null; Log.e(TAG, "Extra: " + data.toString()); try { result = data.getString("results"); Log.d(TAG, "Results: " + result); Log.e(TAG, "Extra: " + data.toString()); message = data.getString("message"); } catch (Exception e) { e.printStackTrace(); } try { JSONObject jsonObject = new JSONObject(result); message = jsonObject.getString("message"); orderId = jsonObject.getString("result"); notificationType = jsonObject.getString("notificationType"); Log.d(TAG, "JSONObject Message: " + message); } catch (JSONException e) { e.printStackTrace(); return; } catch (Exception e) { e.printStackTrace(); return; } try { Log.e(TAG, "Extra: " + data.getString("message")); } catch (Exception e) { e.printStackTrace(); } Log.e(TAG, "FASTVAN APP FOREGROUND: " + BaseActivity.isForeGround()); Log.d(TAG, "Message: " + message); Log.d(TAG, "From: " + from); Log.d(TAG, "Results: " + result); Log.e(TAG, "Extra: " + data.toString()); /* if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } */ // [START_EXCLUDE] /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ if (notificationType != null && notificationType.equals("DRIVER_ASSIGNED")) sendNotification(orderId, message, notificationType); else { sendNotification(message); } // [END_EXCLUDE] }
From source file:com.androidbegin.gcmtutorial.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Log.e(TAG, "Service handle message"); 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.e("tag", extras.toString() + " " + messageType.toString()); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w ww .j av 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("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.e(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); // try { // Thread.sleep(5000); // } catch (InterruptedException e) { // } } Log.e(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification("Received: " + extras.toString()); Log.e(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.example.hellonetwork.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { for (int i = 0; i < loop; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(sleep); } catch (InterruptedException e) { Log.i("INTERRUPT", " "); }//from w w w. j a va 2s. co m } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification("Received: " + extras.toString()); Log.i(TAG, "Received: " + extras.toString()); } } GcmReceiver.completeWakefulIntent(intent); }
From source file:com.ashish.msngr.GCMNotificationIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { for (int i = 0; i < 3; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { }//from w w w. j a v a 2 s.com } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification("" + extras.get(Config.MESSAGE_KEY)); RegisterActivity.msg = (String) extras.get(Config.MESSAGE_KEY); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); //Intent i = new Intent(this,RegisterActivity.class); //i.putExtra("msg",msg); //startActivity(i); }
From source file:co.mindquake.nester.pushNoti.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString(), extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { }/* w w w . j a v a2 s . co m*/ } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification(extras.getString("description"), extras); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:bg.phpgcm2.MyGcmListenerService.java
/** * Called when message is received.//from w w w. 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(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { String st = data.getString("st"); String message = data.getString("mes"); Log.d(TAG, "From: " + from); Log.d(TAG, "Status: " + st); Log.d(TAG, "Message: " + message); Log.d(TAG, "Bundle: " + data); Intent i = new Intent("RECEIVEDMES"); i.putExtra("mes", data.toString()); sendBroadcast(i); if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } // [START_EXCLUDE] /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ sendNotification("Status " + st + "\nMessage " + message); // [END_EXCLUDE] }