List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:org.spaceappschallenge.spacemission.roadmap.mgf.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 != null && !extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w ww .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)) { Log.e(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)) { final Mission mission = new Mission(); Object messageProperty; messageProperty = extras.get("title"); if (messageProperty != null) { mission.title = messageProperty.toString(); } messageProperty = extras.get("summary"); if (messageProperty != null) { mission.summary = messageProperty.toString(); } messageProperty = extras.get("description"); if (messageProperty != null) { mission.description = messageProperty.toString(); } messageProperty = extras.get("image"); if (messageProperty != null) { mission.image = messageProperty.toString(); } messageProperty = extras.get("url"); if (messageProperty != null) { mission.url = messageProperty.toString(); } messageProperty = extras.get("date"); if (messageProperty != null) { // mission.date = messageProperty.toString(); Log.i(TAG, messageProperty.toString()); } sendNotification(mission); Log.i(TAG, mission.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:ro.astazi.andrapp.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, "GcmIntentService IntentService"); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//ww w . j a va2s . 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", "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)) { // 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(extras.getString("title"), extras.getString("message")); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.sourceauditor.sahomemonitor.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { try {/* w w w . ja va2 s .co 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)) { sendNotification("Send error: " + extras.toString(), extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), extras); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. if (USE_NOTIFICATION) { String msg = extras.getString(MainActivity.EXTRA_MESSAGE_FROM_HOME); if (msg == null || msg.trim().isEmpty()) { msg = "Home Alert (no message)"; } sendNotification(msg, extras); } else { sendToMainActivity(extras); } Log.i(TAG, "Received: " + extras.toString()); } } } finally { // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:com.campusconnect.gcm.GcmIntentService.java
@Override protected final void onHandleIntent(final 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 unpacking Bundle /*//w w w .ja v 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. */ switch (messageType) { case GoogleCloudMessaging.MESSAGE_TYPE_DELETED: sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. break; case GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE: if (intent.getStringExtra("NotificationKind").equals("PriceCheckLowerPrices1")) { final String message = getUserMessageForPriceCheckLowerPricesNotif(intent); Handler h = new Handler(Looper.getMainLooper()); h.post(new Runnable() { @Override public void run() { Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } }); } break; case GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR: default: sendNotification("Send error: " + extras.toString()); break; } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.playtech.ezpush.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 www. ja v a 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)) { // 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. showNotification(extras); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:ar.com.martinrevert.argenteam.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { String message;//from w ww. j a v a2s.c o m String tipo; String urlimagen; String urlarticulo; String fecha; Context context = getApplicationContext(); 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)) { generarNotification(context, "Error: " + extras.toString(), "", "", "", ""); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { generarNotification(context, "Deleted messages on server: " + extras.toString(), "", "", "", ""); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Aqui obtengo los datos del mensaje que viene en el Intent. message = intent.getExtras().getString("message"); tipo = intent.getExtras().getString("tipo"); urlimagen = intent.getExtras().getString("urlimagen"); urlarticulo = intent.getExtras().getString("urlarticulo"); fecha = intent.getExtras().getString("fecha"); Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. generarNotification(context, message, urlimagen, urlarticulo, tipo, fecha); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.pinplanet.pintact.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { System.out.println("==== Push Notification: 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 /*// w w w . j a va 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(), extras.getString("customData")); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), extras.getString("customData")); // 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. Log.d(TAG, "Notification Received"); Log.d(TAG, "text: " + extras.getString("text")); Log.d(TAG, "customData: " + extras.getString("customData")); sendNotification(extras.getString("text"), extras.getString("customData")); //Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:sunny.app9ation.xyz.sunny.gcm.MyGcmListenerService.java
/** * Called when message is received.// w w w . j a v a2s . 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. 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:com.example.volunteerhandbook.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 /*//w ww . j a v 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)) { // 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(3000); } 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.roamprocess1.roaming4world.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 ww w . ja v 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. */ String message = extras.getString("price"); System.out.println("GcmIntentService:@" + message); 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); }