List of usage examples for android.os Bundle isEmpty
public boolean isEmpty()
From source file:xyz.ivyxjc.zhihu.list.FragmentTab.java
@Override protected void initImmediateData() { Bundle bundle = getArguments(); if (bundle != null && !bundle.isEmpty()) { mTitleId = bundle.getInt(Constant.LIST_ACTIVITY_NAV_TITLE); mSuffixId = bundle.getInt(Constant.LIST_ACTIVITY_NAV_SUFFIX); } else {//w w w .j a v a 2s . com mTitleId = R.array.develop; mSuffixId = R.array.develop_suffix; } mArraysSuffix = getResources().getStringArray(mSuffixId); mArraysTitle = getResources().getStringArray(mTitleId); dataLoaded(); }
From source file:nz.ac.otago.psyanlab.common.designer.program.object.PickObjectListFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Bundle args = getArguments(); if (args.isEmpty()) { throw new RuntimeException("Missing arguments."); }//from w w w .java 2s. c o m mScope = args.getInt(ARG_SCOPE); mCallerKind = args.getInt(ARG_CALLER_KIND); mCallerId = args.getLong(ARG_CALLER_ID); mFilter = args.getInt(ARG_FILTER); mAdapter = mCallbacks.getObjectSectionListAdapter(mCallerKind, mCallerId, mScope, mFilter); setListAdapter(mAdapter); }
From source file:com.beepscore.android.sunshine.gcm.MyGcmListenerService.java
/** * Called when message is received./*from ww w . ja v a 2 s . 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) { // Unparcel the bundle if (!data.isEmpty()) { 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)) { // this message came from our server, safe to respond to it. 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.itime.team.itime.fragments.QRCodeFragment.java
@NonNull @Override// ww w . j a v a 2 s . com public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.fragment_profile_qrcode); ImageView imageView = (ImageView) dialog.findViewById(R.id.setting_profile_qrcode_img); final Bundle arguments = getArguments(); if (!arguments.isEmpty()) { mUserId = arguments.getString(QRCODE_STRING); } Bitmap qrCodeBitmap; // method1: change a fix dip to pixel //final int dim = DensityUtil.dip2px(getContext(), 600); // method2: get the display size and scale into 7/8 // This assumes the view is full screen, which is a good assumption WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point displaySize = new Point(); display.getSize(displaySize); int width = displaySize.x; int height = displaySize.y; int smallerDimension = width < height ? width : height; final int dim = smallerDimension * 7 / 8; try { qrCodeBitmap = barcodeEncoder.encodeBitmap(mUserId, BarcodeFormat.QR_CODE, dim, dim); imageView.setImageBitmap(qrCodeBitmap); } catch (WriterException e) { Toast.makeText(getActivity(), "QRCode text can not be empty", Toast.LENGTH_SHORT).show(); } return dialog; }
From source file:sunny.app9ation.xyz.sunny.gcm.MyGcmListenerService.java
/** * Called when message is received.//from w w w . j a 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(). */ @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.liferay.mobile.push.util.GoogleServices.java
public JSONObject getPushNotification(Context context, Intent intent) throws PushNotificationReceiverException { String messageType = getMessageType(context, intent); if (!GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { throw new PushNotificationReceiverException("Unknown message type" + messageType); }//from www. j av a 2 s . co m Bundle extras = intent.getExtras(); if ((extras == null) || extras.isEmpty()) { throw new PushNotificationReceiverException("Push notification body is empty."); } String payload = extras.getString("payload", null); if (payload == null) { throw new PushNotificationReceiverException("Push notification without payload."); } try { JSONObject pushNotification = new JSONObject(payload); return pushNotification; } catch (JSONException je) { throw new PushNotificationReceiverException(je); } }
From source file:com.nanodegree.gemma.sunshine.app.gcm.MyGcmListenerService.java
/** * Called when message is received./* ww w .j av 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(). */ @Override public void onMessageReceived(String from, Bundle data) { // Time to unparcel the bundle! if (!data.isEmpty()) { 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. 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) { // JSON parsing failed, so we just let this message go, since GCM is not one // of our critical features. } } Log.i(TAG, "Received: " + data.toString()); } }
From source file:br.com.awa.mylottery.gcm.MyGcmListenerService.java
/** * Called when message is received.// w w w .j a va 2 s . 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(). */ // [START receive_message] @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. //try { //JSONObject jsonObject = new JSONObject(data.getString(EXTRA_DATA)); //String weather = data.getString(EXTRA_WEATHER); String message = data.getString(EXTRA_MESSAGE); String alert = String.format(message); sendNotification(alert); //} catch (JSONException e) { // JSON parsing failed, so we just let this message go, since GCM is not one // of our critical features. //} } Log.i(TAG, "Received: " + data.toString()); } }
From source file:com.coderming.weatherwatch.gcm.MyGcmListenerService.java
/** * Called when message is received.//from ww w . j a 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(). */ @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. 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) { // JSON parsing failed, so we just let this message go, since GCM is not one // of our critical features. } } Log.i(TAG, "Received: " + data.toString()); } }
From source file:com.alexforprog.spareparts.GCM.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (!extras.isEmpty()) { type = Integer.parseInt(extras.getString("type")); title = extras.getString("title"); message = extras.getString("message"); // read extras as sent from server if (type == Global.PUSH_TYPE_NEW_OFFER) { OrderID = Integer.parseInt(extras.getString("OrderID")); }/*from www .j ava2 s.c om*/ sendNotification(message, title, type); } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }