List of usage examples for android.os Bundle size
public int size()
From source file:com.appdynamics.demo.gasp.service.RESTIntentService.java
private static List<BasicNameValuePair> paramsToList(Bundle params) { ArrayList<BasicNameValuePair> formList = new ArrayList<BasicNameValuePair>(params.size()); for (String key : params.keySet()) { Object value = params.get(key); if (value != null) formList.add(new BasicNameValuePair(key, value.toString())); }//from ww w . j av a 2 s .c om return formList; }
From source file:Main.java
/** * Compares two {@link android.os.Bundle Bundles} to check for equality. * * @param a the first {@link android.os.Bundle Bundle} * @param b the second {@link android.os.Bundle Bundle} * @return {@code true} if the two {@link android.os.Bundle Bundles} have identical contents, or are both null *//*from w w w . j a v a 2s. c o m*/ public static boolean areEqual(@Nullable Bundle a, @Nullable Bundle b) { // equal if both null if (a == null && b == null) return true; // unequal if one is null if (a == null || b == null) return false; // check size if (a.size() != b.size()) return false; // get key sets Set<String> bundleAKeys = a.keySet(); Object valueA; Object valueB; // loop keys for (String key : bundleAKeys) { // check key exists in second bundle if (!b.containsKey(key)) return false; // get values valueA = a.get(key); valueB = b.get(key); // check null valued entries if (valueA == null && valueB == null) continue; if (valueA == null || valueB == null) return false; // compare iteratively if they are both bundles if (valueA instanceof Bundle && valueB instanceof Bundle) { if (!areEqual((Bundle) valueA, (Bundle) valueB)) return false; continue; } // check for different values if (!valueA.equals(valueB)) return false; } // passed! return true; }
From source file:com.cloudbees.gasp.loader.RESTLoader.java
private static List<BasicNameValuePair> paramsToList(Bundle params) { ArrayList<BasicNameValuePair> formList = new ArrayList<BasicNameValuePair>(params.size()); for (String key : params.keySet()) { Object value = params.get(key); // We can only put Strings in a form entity, so we call the toString() // method to enforce. We also probably don't need to check for null here // but we do anyway because Bundle.get() can return null. if (value != null) formList.add(new BasicNameValuePair(key, value.toString())); }// w ww . j a v a 2 s .c o m return formList; }
From source file:com.antew.redditinpictures.library.service.RESTService.java
private static List<BasicNameValuePair> paramsToList(Bundle params) { ArrayList<BasicNameValuePair> formList = new ArrayList<BasicNameValuePair>(params.size()); for (String key : params.keySet()) { Object value = params.get(key); // We can only put Strings in a form entity, so we call the toString() // method to enforce. We also probably don't need to check for null here // but we do anyway because Bundle.get() can return null. if (value != null) { formList.add(new BasicNameValuePair(key, value.toString())); }//w ww . ja v a 2 s . c om } return formList; }
From source file:com.zrlh.llkc.funciton.Http_Utility.java
public static boolean isBundleEmpty(Bundle bundle) { if (bundle == null || bundle.size() == 0) { return true; }//from w ww. j av a 2 s . c o m return false; }
From source file:com.sonyericsson.android.drm.drmlicenseservice.DLSHttpClient.java
private static void addParameters(Bundle parameters, HttpRequestBase request) { if (parameters != null && request != null) { Bundle headers = parameters.getBundle(Constants.DRM_KEYPARAM_HTTP_HEADERS); if (headers != null && headers.size() > 0) { for (String headerKey : headers.keySet()) { if (headerKey != null && headerKey.length() > 0) { String headerValue = headers.getString(headerKey); if (headerValue != null && headerValue.length() > 0) { request.setHeader(headerKey, headerValue); }// w w w .j av a2s . c o m } } } } }
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(); }/* w w w. j a va 2s.co m*/ return "null"; }
From source file:com.playhaven.android.push.NotificationBuilder.java
/** * Create a notification from a Bundle, using the provided PendingIntent *///from w w w . java 2 s . c om public Notification makeNotification(Bundle extras, PendingIntent pendingIntent) { try { if (extras == null || extras.size() < 2) { throw new PlayHavenException(); } NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); builder.setContentTitle(extras.getString(Keys.TITLE.name())); builder.setContentText(extras.getString(Keys.TEXT.name())); builder.setAutoCancel(true); builder.setSmallIcon(mContext.getApplicationInfo().icon); // We use the application's icon. builder.setContentIntent(pendingIntent); return builder.getNotification(); } catch (Exception e) { PlayHaven.e("Unable to create Notification from intent."); return null; } }
From source file:com.nagopy.android.xposed.SettingChangedReceiver.java
@Override public void onReceive(Context context, Intent intent) { Object obj = dataObject.get(); if (!StringUtils.equals(intent.getAction(), action) || obj == null) { context.unregisterReceiver(this); return;//from w w w. java 2 s . com } Bundle extras = intent.getExtras(); if (extras == null || extras.size() != 2) { return; } try { // target?value???????? String target = extras.getString("target"); Object value = extras.get("value"); obj.getClass().getField(target).set(obj, value); onDataChanged(); } catch (Throwable t) { Logger.e(getClass().getSimpleName(), Log.getStackTraceString(t)); } }
From source file:edu.cmu.sei.cloudlet.client.ska.adb.InDataService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v(TAG, "Received data."); Bundle extras = intent.getExtras(); Log.v(TAG, "Number of items: " + extras.size()); JSONObject jsonData = new JSONObject(); for (String key : extras.keySet()) { try {//from ww w.j a v a 2 s.c o m jsonData.put(key, extras.getString(key)); } catch (JSONException e) { e.printStackTrace(); } } String result = mDataHandler.handleData(jsonData, this); Log.v(TAG, "Writing result to file."); FileHandler.writeToFile(ADBConstants.OUT_FILE_PATH, result); Log.v(TAG, "Finished writing result to file."); // We don't need this service to run anymore. stopSelf(); return START_NOT_STICKY; }