android.os.Bundle.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(162)

本文整理了Java中android.os.Bundle.isEmpty()方法的一些代码示例,展示了Bundle.isEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.isEmpty()方法的具体详情如下:
包路径:android.os.Bundle
类名称:Bundle
方法名:isEmpty

Bundle.isEmpty介绍

暂无

代码示例

代码示例来源:origin: evernote/android-job

/**
 * 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;
}

代码示例来源:origin: jiajunhui/PlayerBase

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();
}

代码示例来源:origin: stackoverflow.com

if (savedInstanceState.isEmpty())
  Log.i(tag, "Can't restore state because bundle is empty.");
else

代码示例来源:origin: k9mail/k-9

@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;
}

代码示例来源:origin: square/assertj-android

public BundleAssert isNotEmpty() {
 isNotNull();
 assertThat(actual.isEmpty()) //
   .overridingErrorMessage("Expected to not be empty but was.") //
   .isFalse();
 return this;
}

代码示例来源:origin: square/assertj-android

public BundleAssert isEmpty() {
 isNotNull();
 assertThat(actual.isEmpty()) //
   .overridingErrorMessage("Expected to be empty but was not.") //
   .isTrue();
 return this;
}

代码示例来源:origin: journeyapps/zxing-android-embedded

public static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) {
  Bundle extras = intent.getExtras();
  if (extras == null || extras.isEmpty()) {
    return null;

代码示例来源:origin: robolectric/robolectric

@Test
public void isEmpty() {
 assertThat(bundle.isEmpty()).isTrue();
 bundle.putBoolean("foo", true);
 assertThat(bundle.isEmpty()).isFalse();
}

代码示例来源:origin: konmik/nucleus

return map.isEmpty();
}).when(bundle).isEmpty();
doAnswer(new Answer() {
  @Override

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetDataShouldLazilyCreateBundle() throws Exception {
 assertThat(new Message().getData()).isNotNull();
 assertThat(new Message().getData().isEmpty()).isTrue();
}

代码示例来源:origin: robolectric/robolectric

@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();
}

代码示例来源:origin: robolectric/robolectric

@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();
}

代码示例来源:origin: robolectric/robolectric

@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();
}

代码示例来源:origin: stackoverflow.com

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);
 }
}

代码示例来源:origin: stackoverflow.com

@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);
 }

代码示例来源:origin: stackoverflow.com

String messageType = gcm.getMessageType(intent);          if (!extras.isEmpty()) {          if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR
   .equals(messageType)) {
   sendNotification("Send error: " + extras.toString());

代码示例来源:origin: Drivemode/IntentLogger

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;
    }
  }
}

代码示例来源:origin: marzika/Snapprefs

@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);
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public BundleAssert isNotEmpty() {
 isNotNull();
 assertThat(actual.isEmpty()) //
   .overridingErrorMessage("Expected to not be empty but was.") //
   .isFalse();
 return this;
}

代码示例来源:origin: heinrichreimer/android-issue-reporter

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;
  }
}

相关文章

Bundle类方法