/** * Set optional transient extras. <b>WARNING:</b> It's not guaranteed that a transient job will * run at all, e.g. rebooting the device or force closing the app will cancel the job. This is * only helpful for jobs which should start soon and can be cancelled automatically. * * <br> * <br> * * If the passed in bundle is {@code null} or empty, then the previous extras are reset to the default * and the job won't be transient. * * @param extras Bundle containing extras you want the scheduler to hold on to for you. */ public Builder setTransientExtras(@Nullable Bundle extras) { mTransient = extras != null && !extras.isEmpty(); mTransientExtras = mTransient ? new Bundle(extras) : Bundle.EMPTY; return this; }
public synchronized static Bundle obtain(){ for(int i=0;i<POOL_SIZE;i++){ if(mPool.get(i).isEmpty()){ return mPool.get(i); } } PLog.w("BundlePool","<create new bundle object>"); return new Bundle(); }
if (savedInstanceState.isEmpty()) Log.i(tag, "Can't restore state because bundle is empty."); else
@Nullable private Bundle createGossipUpdateBundle(List<String> gossipAcceptedAddresses, List<AutocryptGossipHeader> autocryptGossipHeaders, Date effectiveDate) { Bundle updates = new Bundle(); for (AutocryptGossipHeader autocryptGossipHeader : autocryptGossipHeaders) { boolean isAcceptedAddress = gossipAcceptedAddresses.contains(autocryptGossipHeader.addr.toLowerCase()); if (!isAcceptedAddress) { continue; } AutocryptPeerUpdate update = AutocryptPeerUpdate.create(autocryptGossipHeader.keyData, effectiveDate, false); updates.putParcelable(autocryptGossipHeader.addr, update); } if (updates.isEmpty()) { return null; } return updates; }
public BundleAssert isNotEmpty() { isNotNull(); assertThat(actual.isEmpty()) // .overridingErrorMessage("Expected to not be empty but was.") // .isFalse(); return this; }
public BundleAssert isEmpty() { isNotNull(); assertThat(actual.isEmpty()) // .overridingErrorMessage("Expected to be empty but was not.") // .isTrue(); return this; }
public static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null || extras.isEmpty()) { return null;
return map.isEmpty(); }).when(bundle).isEmpty(); doAnswer(new Answer() { @Override
@Test public void testGetDataShouldLazilyCreateBundle() throws Exception { assertThat(new Message().getData()).isNotNull(); assertThat(new Message().getData().isEmpty()).isTrue(); }
@Test @Config(minSdk = LOLLIPOP) public void getApplicationRestrictionsShouldReturnEmptyBundleIfAppHasNone() { // GIVEN the caller is the device owner shadowOf(devicePolicyManager).setDeviceOwner(testComponent); // GIVEN an app has no restrictions String app = "com.example.app"; // WHEN DevicePolicyManager#getApplicationRestrictions is called to get the restrictions of the // app // THEN it should return the empty bundle assertThat(devicePolicyManager.getApplicationRestrictions(testComponent, app).isEmpty()) .isTrue(); }
@Test public void testObtainWithMessage() throws Exception { Bundle b = new Bundle(); Message m = new Message(); m.arg1 = 10; m.arg2 = 42; m.obj = "obj"; m.what = 24; m.setData(b); m.setTarget(new Handler()); Message m2 = Message.obtain(m); assertThat(m2.arg1).isEqualTo(m.arg1); assertThat(m2.arg2).isEqualTo(m.arg2); assertThat(m2.obj).isEqualTo(m.obj); assertThat(m2.what).isEqualTo(m.what); assertThat(m2.getTarget()).isEqualTo(m.getTarget()); assertThat(m2.getData()).isNotNull(); assertThat(m2.getData().isEmpty()).isTrue(); }
@Test public void testCopyFrom() throws Exception { Bundle b = new Bundle(); Message m = new Message(); m.arg1 = 10; m.arg2 = 42; m.obj = "obj"; m.what = 24; m.setData(b); m.setTarget(new Handler()); Message m2 = new Message(); m2.copyFrom(m); assertThat(m2.arg1).isEqualTo(m.arg1); assertThat(m2.arg2).isEqualTo(m.arg2); assertThat(m2.obj).isEqualTo(m.obj); assertThat(m2.what).isEqualTo(m.what); assertThat(m2.getTarget()).isNull(); assertThat(m2.getData()).isNotNull(); assertThat(m2.getData().isEmpty()).isTrue(); }
public class GCMprocess extends IntentService { public GCMprocess() { super("GCMIntentService"); } @Override protected void onHandleIntent(final Intent intent) { final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); final String messageType = gcm.getMessageType(intent); final Bundle extras = intent.getExtras(); if ((!extras.isEmpty()) && (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType))) { // This method will be fired for each location of each user sent by your cron'ed script String longitude = extras.getString("longitude"); String latitude = extras.getString("latitude"); String username = extras.getString("username"); // And this places the content in your google map: private GoogleMap mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); mMap.addMarker(new MarkerOptions().position(new LatLng(Double.parseDouble(longitude), Double.parseDouble(latitude))).title("User " + username)); } GCMBroadcastReceiver.completeWakefulIntent(intent); } }
@Override private View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ... if (savedInstanceState != null && !savedInstanceState.isEmpty()){ msDialogMessage = savedInstanceState.getString(STATE_DAILOG_MSG); } else{ Utils.setKeyboardFocus(mEditTextUserName); } ... } /** * Used to set focus and show keyboard (if needed) for a specified text field * @author Ty Smith * @param primaryTextField */ public static void setKeyboardFocus(final EditText primaryTextField) { (new Handler()).postDelayed(new Runnable() { public void run() { primaryTextField.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0)); primaryTextField.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0)); } }, 100); }
String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR .equals(messageType)) { sendNotification("Send error: " + extras.toString());
public static boolean hasExtras(Bundle extras) { try { return (extras != null && !extras.isEmpty()); } catch (BadParcelableException e) { Log.w("IntentLogger", "Extra contains unknown class instance: ", e); return true; } } }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (!extras.isEmpty()) { // read extras as sent from server String message = extras.getString("message"); if(message == null || message.isEmpty()) return; sendNotification(message); } // Release the wake lock provided by the WakefulBroadcastReceiver. GCMBroadcastReceiver.completeWakefulIntent(intent); }
public BundleAssert isNotEmpty() { isNotNull(); assertThat(actual.isEmpty()) // .overridingErrorMessage("Expected to not be empty but was.") // .isFalse(); return this; }
public static ExtraInfo fromBundle(Bundle bundle) { ExtraInfo extraInfo = new ExtraInfo(); if (bundle == null || bundle.isEmpty()) { return extraInfo; } for (String key : bundle.keySet()) { extraInfo.put(key, bundle.getString(key)); } return extraInfo; } }