本文整理了Java中android.content.Intent.filterEquals()
方法的一些代码示例,展示了Intent.filterEquals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.filterEquals()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:filterEquals
暂无
代码示例来源:origin: android-hacker/VirtualXposed
IntentBindRecord peekBinding(Intent service) {
synchronized (bindings) {
for (IntentBindRecord bindRecord : bindings) {
if (bindRecord.intent.filterEquals(service)) {
return bindRecord;
}
}
}
return null;
}
代码示例来源:origin: robolectric/robolectric
@Override
@Implementation
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || realPendingIntent.getClass() != o.getClass()) return false;
ShadowPendingIntent that = Shadow.extract((PendingIntent) o);
String packageName = savedContext == null ? null : savedContext.getPackageName();
String thatPackageName = that.savedContext == null ? null : that.savedContext.getPackageName();
if (!Objects.equals(packageName, thatPackageName)) {
return false;
}
if (this.savedIntents.length != that.savedIntents.length) {
return false;
}
for (int i = 0; i < this.savedIntents.length; i++) {
if (!this.savedIntents[i].filterEquals(that.savedIntents[i])) {
return false;
}
}
if (this.requestCode != that.requestCode) {
return false;
}
return true;
}
代码示例来源:origin: robolectric/robolectric
@Implementation
protected void cancel(PendingIntent operation) {
ShadowPendingIntent shadowPendingIntent = Shadow.extract(operation);
final Intent toRemove = shadowPendingIntent.getSavedIntent();
final int requestCode = shadowPendingIntent.getRequestCode();
for (ScheduledAlarm scheduledAlarm : scheduledAlarms) {
if (scheduledAlarm.operation != null) {
ShadowPendingIntent scheduledShadowPendingIntent = Shadow.extract(scheduledAlarm.operation);
final Intent scheduledIntent = scheduledShadowPendingIntent.getSavedIntent();
final int scheduledRequestCode = scheduledShadowPendingIntent.getRequestCode();
if (scheduledIntent.filterEquals(toRemove) && scheduledRequestCode == requestCode) {
scheduledAlarms.remove(scheduledAlarm);
break;
}
}
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void send_shouldFillInIntentData() throws Exception {
Intent intent = new Intent("action");
Context context = Robolectric.setupActivity(Activity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 99, intent, 100);
Activity otherContext = Robolectric.setupActivity(Activity.class);
Intent fillIntent = new Intent().putExtra("TEST", 23);
pendingIntent.send(otherContext, 0, fillIntent);
Intent i = shadowOf(otherContext).getNextStartedActivity();
assertThat(i).isNotNull();
assertThat(i.filterEquals(intent)).isTrue(); // Ignore extras.
assertThat(i.getIntExtra("TEST", -1)).isEqualTo(23);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void send_shouldNotReusePreviouslyFilledInIntentData() throws Exception {
Intent intent = new Intent("action");
Context context = Robolectric.setupActivity(Activity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 99, intent, 100);
Activity otherContext = Robolectric.setupActivity(Activity.class);
Intent firstFillIntent = new Intent().putExtra("KEY1", 23).putExtra("KEY2", 24);
pendingIntent.send(otherContext, 0, firstFillIntent);
ShadowActivity shadowActivity = shadowOf(otherContext);
shadowActivity.clearNextStartedActivities();
Intent secondFillIntent = new Intent().putExtra("KEY1", 50);
pendingIntent.send(otherContext, 0, secondFillIntent);
Intent i = shadowActivity.getNextStartedActivity();
assertThat(i).isNotNull();
assertThat(i.filterEquals(intent)).isTrue(); // Ignore extras.
assertThat(i.getIntExtra("KEY1", -1)).isEqualTo(50);
assertThat(i.hasExtra("KEY2")).isFalse();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldHaveStoppedServiceByStartedComponent() {
ShadowApplication shadowApplication = shadowOf(context);
Activity activity = Robolectric.setupActivity(Activity.class);
ComponentName componentName = new ComponentName("package.test", "package.test.TestClass");
Intent startServiceIntent = new Intent().setComponent(componentName);
ComponentName startedComponent = activity.startService(startServiceIntent);
assertThat(startedComponent.getPackageName()).isEqualTo("package.test");
assertThat(startedComponent.getClassName()).isEqualTo("package.test.TestClass");
Intent stopServiceIntent = new Intent().setComponent(startedComponent);
stopServiceIntent.putExtra("someExtra", "someValue");
boolean wasRunning = activity.stopService(stopServiceIntent);
assertTrue(wasRunning);
final Intent nextStoppedService = shadowApplication.getNextStoppedService();
assertThat(nextStoppedService.filterEquals(startServiceIntent)).isTrue();
assertThat(nextStoppedService.getStringExtra("someExtra")).isEqualTo("someValue");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void send_shouldNotUsePreviouslyFilledInLastIntentData() throws Exception {
Intent[] intents = {new Intent("first"), new Intent("second")};
Context context = Robolectric.setupActivity(Activity.class);
PendingIntent pendingIntent = PendingIntent.getActivities(context, 99, intents, 100);
Activity otherContext = Robolectric.setupActivity(Activity.class);
Intent firstFillIntent = new Intent();
firstFillIntent.putExtra("KEY1", 23);
firstFillIntent.putExtra("KEY2", 24);
pendingIntent.send(otherContext, 0, firstFillIntent);
ShadowActivity shadowActivity = shadowOf(otherContext);
shadowActivity.clearNextStartedActivities();
Intent secondFillIntent = new Intent();
secondFillIntent.putExtra("KEY1", 50);
pendingIntent.send(otherContext, 0, secondFillIntent);
Intent second = shadowActivity.getNextStartedActivity();
assertThat(second).isNotNull();
assertThat(second.filterEquals(intents[1])).isTrue(); // Ignore extras.
assertThat(second.getIntExtra("KEY1", -1)).isEqualTo(50);
assertThat(second.hasExtra("KEY2")).isFalse();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void send_shouldFillInLastIntentData() throws Exception {
Intent[] intents = {new Intent("first"), new Intent("second")};
Context context = Robolectric.setupActivity(Activity.class);
PendingIntent pendingIntent = PendingIntent.getActivities(context, 99, intents, 100);
Activity otherContext = Robolectric.setupActivity(Activity.class);
Intent fillIntent = new Intent();
fillIntent.putExtra("TEST", 23);
pendingIntent.send(otherContext, 0, fillIntent);
ShadowActivity shadowActivity = shadowOf(otherContext);
Intent second = shadowActivity.getNextStartedActivity();
assertThat(second).isNotNull();
assertThat(second.filterEquals(intents[1])).isTrue(); // Ignore extras.
assertThat(second.getIntExtra("TEST", -1)).isEqualTo(23);
Intent first = shadowActivity.getNextStartedActivity();
assertThat(first).isNotNull();
assertThat(first).isSameAs(intents[0]);
assertThat(first.hasExtra("TEST")).isFalse();
}
代码示例来源:origin: robolectric/robolectric
private static PendingIntent getCreatedIntentFor(Type type, Intent[] intents, int requestCode,
int flags) {
synchronized (lock) {
for (PendingIntent createdIntent : createdIntents) {
ShadowPendingIntent shadowPendingIntent = Shadow.extract(createdIntent);
if (isOneShot(shadowPendingIntent.flags) != isOneShot(flags)) {
continue;
}
if (isMutable(shadowPendingIntent.flags) != isMutable(flags)) {
continue;
}
if (shadowPendingIntent.type != type) {
continue;
}
if (shadowPendingIntent.requestCode != requestCode) {
continue;
}
// The last Intent in the array acts as the "significant element" for matching as per
// {@link #getActivities(Context, int, Intent[], int)}.
Intent savedIntent = shadowPendingIntent.getSavedIntent();
Intent targetIntent = intents[intents.length - 1];
if (savedIntent == null ? targetIntent == null : savedIntent.filterEquals(targetIntent)) {
return createdIntent;
}
}
return null;
}
}
代码示例来源:origin: Trumeet/MiPushFramework
@Test public void testBroadcast() {
sCondomProcessPackageManager.mCondom.mOutboundJudge = mBlockAllJudge;
final Intent intent = new Intent();
mIntent = null;
context().sendBroadcast(intent);
assertOutboundJudgeCalled(0);
assertNull(mIntent);
mIntent = null;
context().sendBroadcast(new Intent(intent.setPackage("a.b.c")));
assertOutboundJudgeCalled(1);
assertNotNull(mIntent);
assertTrue(mIntent.filterEquals(intent));
}
代码示例来源:origin: bzsome/VirtualApp-x326
IntentBindRecord peekBinding(Intent service) {
synchronized (bindings) {
for (IntentBindRecord bindRecord : bindings) {
if (bindRecord.intent.filterEquals(service)) {
return bindRecord;
}
}
}
return null;
}
代码示例来源:origin: darkskygit/VirtualApp
IntentBindRecord peekBinding(Intent service) {
synchronized (bindings) {
for (IntentBindRecord bindRecord : bindings) {
if (bindRecord.intent.filterEquals(service)) {
return bindRecord;
}
}
}
return null;
}
代码示例来源:origin: org.robolectric/shadows-core
private void internalSet(int type, long triggerAtTime, long interval, PendingIntent operation) {
Intent intent = Shadows.shadowOf(operation).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : scheduledAlarms) {
Intent scheduledIntent = Shadows.shadowOf(scheduledAlarm.operation).getSavedIntent();
if (scheduledIntent.filterEquals(intent)) {
scheduledAlarms.remove(scheduledAlarm);
break;
}
}
scheduledAlarms.add(new ScheduledAlarm(type, triggerAtTime, interval, operation));
}
代码示例来源:origin: org.robolectric/shadows-core
@Implementation
public void cancel(PendingIntent pendingIntent) {
final Intent intentTypeToRemove = Shadows.shadowOf(pendingIntent).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : new ArrayList<ScheduledAlarm>(scheduledAlarms)) {
final Intent alarmIntent = Shadows.shadowOf(scheduledAlarm.operation).getSavedIntent();
if (intentTypeToRemove.filterEquals(alarmIntent)) {
scheduledAlarms.remove(scheduledAlarm);
}
}
}
代码示例来源:origin: org.robolectric/shadows-core-v23
private void internalSet(int type, long triggerAtTime, long interval, PendingIntent operation) {
Intent intent = Shadows.shadowOf(operation).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : scheduledAlarms) {
Intent scheduledIntent = Shadows.shadowOf(scheduledAlarm.operation).getSavedIntent();
if (scheduledIntent.filterEquals(intent)) {
scheduledAlarms.remove(scheduledAlarm);
break;
}
}
scheduledAlarms.add(new ScheduledAlarm(type, triggerAtTime, interval, operation));
}
代码示例来源:origin: com.github.japgolly.android.test/robolectric
private void internalSet(int type, long triggerAtTime, long interval, PendingIntent operation) {
Intent intent = shadowOf(operation).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : scheduledAlarms) {
Intent scheduledIntent = shadowOf(scheduledAlarm.operation).getSavedIntent();
if (scheduledIntent.filterEquals(intent)) {
scheduledAlarms.remove(scheduledAlarm);
break;
}
}
scheduledAlarms.add(new ScheduledAlarm(type, triggerAtTime, interval, operation));
}
代码示例来源:origin: org.robolectric/framework
private void internalSet(int type, long triggerAtTime, long interval, PendingIntent operation) {
Intent intent = Shadows.shadowOf(operation).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : scheduledAlarms) {
Intent scheduledIntent = Shadows.shadowOf(scheduledAlarm.operation).getSavedIntent();
if (scheduledIntent.filterEquals(intent)) {
scheduledAlarms.remove(scheduledAlarm);
break;
}
}
scheduledAlarms.add(new ScheduledAlarm(type, triggerAtTime, interval, operation));
}
代码示例来源:origin: org.robolectric/shadows-core-v23
@Implementation
public void cancel(PendingIntent pendingIntent) {
final Intent intentTypeToRemove = Shadows.shadowOf(pendingIntent).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : new ArrayList<ScheduledAlarm>(scheduledAlarms)) {
final Intent alarmIntent = Shadows.shadowOf(scheduledAlarm.operation).getSavedIntent();
if (intentTypeToRemove.filterEquals(alarmIntent)) {
scheduledAlarms.remove(scheduledAlarm);
}
}
}
代码示例来源:origin: com.github.japgolly.android.test/robolectric
@Implementation
public void cancel(PendingIntent pendingIntent) {
final Intent intentTypeToRemove = shadowOf(pendingIntent).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : new ArrayList<ScheduledAlarm>(scheduledAlarms)) {
final Intent alarmIntent = shadowOf(scheduledAlarm.operation).getSavedIntent();
if (intentTypeToRemove.filterEquals(alarmIntent)) {
scheduledAlarms.remove(scheduledAlarm);
}
}
}
代码示例来源:origin: org.robolectric/framework
@Implementation
public void cancel(PendingIntent pendingIntent) {
final Intent intentTypeToRemove = Shadows.shadowOf(pendingIntent).getSavedIntent();
for (ScheduledAlarm scheduledAlarm : new ArrayList<ScheduledAlarm>(scheduledAlarms)) {
final Intent alarmIntent = Shadows.shadowOf(scheduledAlarm.operation).getSavedIntent();
if (intentTypeToRemove.filterEquals(alarmIntent)) {
scheduledAlarms.remove(scheduledAlarm);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!