List of usage examples for android.os Bundle toString
@Override public synchronized String toString()
From source file:Main.java
public static String printBundle(Bundle bundle) { StringBuilder sb = new StringBuilder(); sb.append("Bundle: "); if (bundle != null) { sb.append(bundle.toString()); sb.append("\n"); Set<String> keys = bundle.keySet(); for (String it : keys) { sb.append(" "); sb.append(it);/*from ww w. j a v a 2 s . c o m*/ sb.append(": "); sb.append(bundle.get(it).toString()); sb.append("\n"); } } else { sb.append("(null)"); } return sb.toString(); }
From source file:Main.java
public static void registerNewSourceSinkConnection(int counter, Bundle bundle) { Log.i("PEP", "in registerNewSourceSinkConnection(int counter, Bundle bundle)" + counter + " " + bundle.toString()); int taintInfoKeyCounter = 0; if (bundle != null) { for (String intentKey : bundle.keySet()) { if (intentKey.startsWith(keyBaseName)) { String possibleNumber = intentKey.substring(keyBaseName.length()); if (possibleNumber.length() > 0 && TextUtils.isDigitsOnly(possibleNumber)) { int currentCounter = Integer.parseInt(possibleNumber); if (taintInfoKeyCounter < currentCounter) taintInfoKeyCounter = currentCounter; }/*from www.java 2 s. c o m*/ } } if (taintInfoKeyCounter == 0) { Log.i("PEP", "bundle:" + bundle.toString()); if (bundle.containsKey(keyBaseName)) { String taintSourceCats = bundle.getString(keyBaseName); String[] allCats = taintSourceCats.split(","); sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats))); } } else { if (bundle.containsKey(keyBaseName + taintInfoKeyCounter)) { String taintSourceCats = bundle.getString(keyBaseName + taintInfoKeyCounter); String[] allCats = taintSourceCats.split(","); sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats))); } } } }
From source file:de.ncoder.sensorsystem.android.logging.JSONUtils.java
private static Object wrapBundle(Bundle b) { try {/*from w w w.j av a2s .c o m*/ JSONObject json = new JSONObject(); for (String key : b.keySet()) { json.put(key, wrap(b.get(key))); } return json; } catch (JSONException e) { return b.toString() + " threw " + e.toString(); } }
From source file:Main.java
public static void registerNewSourceSinkConnection(int counter, Bundle bundle) { Log.i("PEP", "in registerNewSourceSinkConnection(int counter, Bundle bundle)"); int taintInfoKeyCounter = 0; if (bundle != null) { for (String intentKey : bundle.keySet()) { if (intentKey.startsWith(keyBaseName)) { String possibleNumber = intentKey.substring(keyBaseName.length()); if (possibleNumber.length() > 0 && TextUtils.isDigitsOnly(possibleNumber)) { int currentCounter = Integer.parseInt(possibleNumber); if (taintInfoKeyCounter < currentCounter) taintInfoKeyCounter = currentCounter; }//from w ww.java2 s . c om } } if (taintInfoKeyCounter == 0) { Log.i("PEP", "bundle:" + bundle.toString()); if (bundle.containsKey(keyBaseName)) { String taintSourceCats = bundle.getString(keyBaseName); String[] allCats = taintSourceCats.split(","); sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats))); } } else { if (bundle.containsKey(keyBaseName + taintInfoKeyCounter)) { String taintSourceCats = bundle.getString(keyBaseName + taintInfoKeyCounter); String[] allCats = taintSourceCats.split(","); sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats))); } } } }
From source file:com.google.samples.apps.gcmplayground.MyGcmListenerService.java
/** * Called when message is received./*from w w w . j a va2s. 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(). */ @Override public void onMessageReceived(String from, Bundle data) { super.onMessageReceived(from, data); Log.d(TAG, data.toString()); Intent downstreamMessageIntent = new Intent(RegistrationConstants.NEW_DOWNSTREAM_MESSAGE); downstreamMessageIntent.putExtra(RegistrationConstants.SENDER_ID, from); downstreamMessageIntent.putExtra(RegistrationConstants.EXTRA_KEY_BUNDLE, data); LocalBroadcastManager.getInstance(this).sendBroadcast(downstreamMessageIntent); }
From source file:android.support.v7.media.RemotePlaybackClient.java
static String bundleToString(Bundle bundle) { if (bundle != null) { bundle.size(); // force bundle to be unparcelled return bundle.toString(); }//from w ww.j ava 2 s . c o m return "null"; }
From source file:GCMService.java
@Override public void onMessageReceived(String from, Bundle data) { super.onMessageReceived(from, data); Log.i("GCMService", "onMessageReceived(): " + data.toString()); sendNotification(data.toString());//from www . j ava 2 s .com }
From source file:com.packpublishing.asynchronousandroid.chapter10.NotificationGCMHandler.java
@Override public void onMessageReceived(String from, Bundle data) { Log.i(TAG, "Received message from GCM " + data.toString() + " to " + from); if (from.equals(FORUM_TOPIC)) { Log.i(TAG, "Received message from forum topic"); Intent intent = new Intent(MSG_DELIVERY); intent.putExtra(USERNAME_KEY, data.getString(USERNAME_KEY)); intent.putExtra(TEXT_KEY, data.getString(TEXT_KEY)); Log.i(TAG, "Sending broacast message"); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } else if (data.getString("type").startsWith("my_notifications")) { createNotification(data.getString("title"), data.getString("body")); }/*from w w w. jav a2 s .co m*/ }
From source file:com.mozilla.simplepush.simplepushdemoapp.GcmIntentService.java
/** Display the notification content via the Notification bar * * @param bundle Data bundle from GCM//from w w w.j a v a 2 s .c o m */ private void displayNotification(Bundle bundle) { Log.d(TAG, "Got GCM notification: " + bundle.toString()); String msg = bundle.getString("Msg"); // Server sends data as "Msg" String ver = bundle.getString("Ver"); // and version as "Ver" String display = msg + " (" + ver + ")"; // Currently this displays the notification. One can easily presume that this is not // required and that your app could do more interesting things internally. NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle("SimplePush Demo Notification") .setStyle(new NotificationCompat.BigTextStyle().bigText(display)).setContentText(display); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.android.anton.pushnotificationwithgcm.GCMUtil.MyGcmListenerService.java
/** * Called when message is received.// w w w . j av a 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) { Log.d("GCMMessage", data.toString()); String message = data.getString("message"); 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(message); // [END_EXCLUDE] }