List of usage examples for android.os Bundle isEmpty
public boolean isEmpty()
From source file:com.miloisbadboy.net.Utility.java
/** * Construct a url encoded entity by parameters . * /*from w w w.j a v a 2s . co m*/ * @param bundle * :parameters key pairs * @return UrlEncodedFormEntity: encoed entity */ public static UrlEncodedFormEntity getPostParamters(Bundle bundle) throws RequestException { if (bundle == null || bundle.isEmpty()) { return null; } try { List<NameValuePair> form = new ArrayList<NameValuePair>(); for (String key : bundle.keySet()) { form.add(new BasicNameValuePair(key, bundle.getString(key))); } UrlEncodedFormEntity entity = new UrlEncodedFormEntity(form, "UTF-8"); return entity; } catch (UnsupportedEncodingException e) { throw new RequestException(e); } }
From source file:com.dongfang.dicos.sina.UtilSina.java
/** * Construct a url encoded entity by parameters . * /*from w ww.ja va 2 s . co m*/ * @param bundle * :parameters key pairs * @return UrlEncodedFormEntity: encoed entity */ public static UrlEncodedFormEntity getPostParamters(Bundle bundle) throws WeiboException { if (bundle == null || bundle.isEmpty()) { return null; } try { List<NameValuePair> form = new ArrayList<NameValuePair>(); for (String key : bundle.keySet()) { form.add(new BasicNameValuePair(key, bundle.getString(key))); } UrlEncodedFormEntity entity = new UrlEncodedFormEntity(form, "UTF-8"); return entity; } catch (UnsupportedEncodingException e) { throw new WeiboException(e); } }
From source file:com.github.michalbednarski.intentslab.browser.ComponentInfoFragment.java
public static CharSequence dumpMetaData(final Context context, final String packageName, Bundle metaData) { FormattedTextBuilder text = new FormattedTextBuilder(); Context foreignContext = null; try {//from w w w. j a va 2s.c om foreignContext = context.createPackageContext(packageName, 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } if (metaData != null && !metaData.isEmpty()) { text.appendHeader(context.getString(R.string.metadata_header)); for (String key : metaData.keySet()) { Object value = metaData.get(key); if (value instanceof Integer) { // TODO resource? if (foreignContext != null) { text.appendValueNoNewLine(key, value.toString()); // Integers can point to resources final int resId = (Integer) value; if (resId == 0) { continue; } // [View as XML] link try { foreignContext.getResources().getXml(resId); text.appendClickable(context.getString(R.string.view_as_xml_resource), new ClickableSpan() { @Override public void onClick(View widget) { context.startActivity(new Intent(context, SingleFragmentActivity.class) .putExtra(SingleFragmentActivity.EXTRA_FRAGMENT, XmlViewerFragment.class.getName()) .putExtra(XmlViewerFragment.ARG_PACKAGE_NAME, packageName) .putExtra(XmlViewerFragment.ARG_RESOURCE_ID, resId)); } }); } catch (Resources.NotFoundException ignored) { } } // Other types } else if (value instanceof Float) { text.appendValueNoNewLine(key, value.toString() + (((Float) value) % 1f == 0f ? "" : " (float)")); } else if (value instanceof Boolean) { text.appendValueNoNewLine(key, value.toString()); } else if (value instanceof String) { text.appendValueNoNewLine(key, "\"" + value + "\""); } } } return text.getText(); }
From source file:com.haoqee.chatsdk.net.Utility.java
/** * Construct a url encoded entity by parameters . * // w ww.ja v a 2 s . c o m * @param bundle * :parameters key pairs * @return UrlEncodedFormEntity: encoed entity */ public static UrlEncodedFormEntity getPostParamters(Bundle bundle) { if (bundle == null || bundle.isEmpty()) { return null; } try { List<NameValuePair> form = new ArrayList<NameValuePair>(); for (String key : bundle.keySet()) { form.add(new BasicNameValuePair(key, bundle.getString(key))); } UrlEncodedFormEntity entity = new UrlEncodedFormEntity(form, "UTF-8"); return entity; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }
From source file:br.com.arlsoft.pushclient.PushClientModule.java
public static HashMap convertBundleToHashMap(Bundle resource) { HashMap map = new HashMap(); if (resource == null || resource.isEmpty()) return map; for (String key : resource.keySet()) { map.put(key, resource.get(key)); }/*from w w w . j a v a 2s . c o m*/ return map; }
From source file:com.meetingninja.csse.DummyFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.fragment_dummy, container, false); TextView txt = (TextView) v.findViewById(R.id.TextView1); Bundle args = getArguments(); if (args != null && !args.isEmpty()) { txt.setText(args.getString("Content")); }// w w w . j av a 2 s. c o m return v; }
From source file:com.sagar.sunshine.gcm.MyGcmListenerService.java
/** * Called when message is received.//from w w w . j a v a 2s. 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) { 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(); } if ((senderId).equals(from)) { try { JSONObject jsonObject = new JSONObject(data.getString(EXTRA_DATA)); String weather = jsonObject.getString(EXTRA_WEATHER); String location = jsonObject.getString(EXTRA_LOCATION); String alert = String.format(getString(R.string.gcm_weather_alert), weather, location); sendNotification(alert); } catch (JSONException e) { e.printStackTrace(); } } Log.i(TAG, "Received: " + data.toString()); } }
From source file:com.android.google.gcm.GCMBaseIntentService.java
@Override protected final void onHandleIntent(final Intent intent) { final Bundle bundle = intent.getExtras(); if (!bundle.isEmpty()) { final String messageType = GoogleCloudMessaging.getInstance(this).getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { this.onSendError(); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { this.onMessageDeleted(Integer.parseInt(intent.getStringExtra("total_deleted"))); //$NON-NLS-1$ } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { this.onMessageReceived(intent); }/*from w w w .j a v a 2 s . com*/ } WakefulBroadcastReceiver.completeWakefulIntent(intent); }
From source file:org.simlar.GcmBroadcastReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { Lg.init(context);//w w w . ja v a 2s .c o m final Bundle extras = intent.getExtras(); if (extras.isEmpty()) { Lg.e(LOGTAG, "received Google Cloud Messaging Event with empty extras"); return; } final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); if (gcm == null) { Lg.e(LOGTAG, "unable to instantiate Google Cloud Messaging"); return; } final String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Lg.i(LOGTAG, "received: ", extras); startWakefulService(context, intent .setComponent(new ComponentName(context.getPackageName(), SimlarService.class.getName()))); setResultCode(Activity.RESULT_OK); } else if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Lg.e(LOGTAG, "send error: ", extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Lg.e(LOGTAG, "deleted messages on server: ", extras); } else { Lg.e(LOGTAG, "received Google Cloud Messaging Event with unknown message type: ", messageType); } }
From source file:notification.receiveSMSService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (!extras.isEmpty()) { // has effect of unparcelling Bundle final String msg = extras.getString("SMS"); }/*from w w w . j a v a 2 s . c o m*/ }