本文整理了Java中android.content.Intent.getComponent()
方法的一些代码示例,展示了Intent.getComponent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getComponent()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getComponent
暂无
代码示例来源:origin: robolectric/robolectric
protected ComponentName startService(Intent intent) {
startedServices.add(new Intent.FilterComparison(intent));
if (intent.getComponent() != null) {
return intent.getComponent();
}
return new ComponentName("some.service.package", "SomeServiceName-FIXME");
}
代码示例来源:origin: robolectric/robolectric
public Intent getIntent() {
Intent intent = this.intent == null ? new Intent(RuntimeEnvironment.application, component.getClass()) : this.intent;
if (intent.getComponent() == null) {
intent.setClass(RuntimeEnvironment.application, component.getClass());
}
return intent;
}
代码示例来源:origin: robolectric/robolectric
private static ComponentName getComponentForIntent(Intent intent) {
ComponentName component = intent.getComponent();
if (component == null) {
if (intent.getSelector() != null) {
intent = intent.getSelector();
component = intent.getComponent();
}
}
return component;
}
代码示例来源:origin: Tencent/tinker
@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
if (processIntent(cl, intent)) {
return super.newActivity(cl, intent.getComponent().getClassName(), intent);
} else {
return super.newActivity(cl, className, intent);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetClassName() throws Exception {
Intent intent = new Intent();
Class<? extends ShadowIntentTest> thisClass = getClass();
intent.setClassName("package.name", thisClass.getName());
assertSame(thisClass.getName(), intent.getComponent().getClassName());
assertEquals("package.name", intent.getComponent().getPackageName());
assertSame(intent.getComponent().getClassName(), thisClass.getName());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetClassThroughConstructor() throws Exception {
Intent intent = new Intent(ApplicationProvider.getApplicationContext(), getClass());
assertThat(intent.getComponent().getClassName()).isEqualTo(getClass().getName());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetClass() throws Exception {
Intent intent = new Intent();
Class<? extends ShadowIntentTest> thisClass = getClass();
Intent output = intent.setClass(ApplicationProvider.getApplicationContext(), thisClass);
assertSame(output, intent);
assertThat(intent.getComponent().getClassName()).isEqualTo(thisClass.getName());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void constructor_shouldSetComponentAndActionAndData() {
Intent intent =
new Intent(
"roboaction",
Uri.parse("http://www.robolectric.org"),
ApplicationProvider.getApplicationContext(),
Activity.class);
assertThat(intent.getComponent()).isEqualTo(new ComponentName("org.robolectric", "android.app.Activity"));
assertThat(intent.getAction()).isEqualTo("roboaction");
assertThat(intent.getData()).isEqualTo(Uri.parse("http://www.robolectric.org"));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getParentActivityIntent() {
Activity activity = setupActivity(ChildActivity.class);
assertThat(activity.getParentActivityIntent().getComponent().getClassName())
.isEqualTo(ParentActivity.class.getName());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void queryActivityIcons_Match() throws Exception {
Intent i = new Intent();
i.setComponent(new ComponentName(TEST_PACKAGE_NAME, ""));
Drawable d = new BitmapDrawable();
shadowPackageManager.addActivityIcon(i, d);
assertThat(packageManager.getActivityIcon(i)).isSameAs(d);
assertThat(packageManager.getActivityIcon(i.getComponent())).isSameAs(d);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void inflate_shouldParseIntentContainedInPreference() throws Exception {
final PreferenceScreen screen = inflatePreferenceActivity();
final Preference intentPreference = screen.findPreference("intent");
Intent intent = intentPreference.getIntent();
assertThat(intent).isNotNull();
assertThat(intent.getAction()).isEqualTo("action");
assertThat(intent.getData()).isEqualTo(Uri.parse("tel://1235"));
assertThat(intent.getType()).isEqualTo("application/text");
assertThat(intent.getComponent().getClassName()).isEqualTo("org.robolectric.test.Intent");
assertThat(intent.getComponent().getPackageName()).isEqualTo("org.robolectric");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void startIntentSender_serviceIntent() throws IntentSender.SendIntentException {
PendingIntent intent =
PendingIntent.getService(
context,
0,
new Intent().setClassName(context, "ServiceIntent"),
PendingIntent.FLAG_UPDATE_CURRENT);
context.startIntentSender(intent.getIntentSender(), null, 0, 0, 0);
assertThat(shadowOf(context).getNextStartedService().getComponent().getClassName())
.isEqualTo("ServiceIntent");
}
代码示例来源:origin: robolectric/robolectric
@Test
public void onBindShouldSetIntentComponentWithCustomIntentWithoutComponentSet() throws Exception {
MyService myService = Robolectric.buildService(MyService.class, new Intent(Intent.ACTION_VIEW)).bind().get();
assertThat(myService.boundIntent.getAction()).isEqualTo(Intent.ACTION_VIEW);
assertThat(myService.boundIntent.getComponent()).isEqualTo(componentName);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void onBindShouldSetIntentComponentWithCustomIntentWithoutComponentSet() throws Exception {
MyService myService = Robolectric.buildIntentService(MyService.class, new Intent(Intent.ACTION_VIEW)).bind().get();
assertThat(myService.boundIntent.getAction()).isEqualTo(Intent.ACTION_VIEW);
assertThat(myService.boundIntent.getComponent()).isEqualTo(componentName);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void onStartCommandShouldSetIntentAndFlags() throws Exception {
MyService myService = controller.create().startCommand(3, 4).get();
assertThat(myService.startIntent).isNotNull();
assertThat(myService.startIntent.getComponent()).isEqualTo(componentName);
assertThat(myService.startFlags).isEqualTo(3);
assertThat(myService.startId).isEqualTo(4);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldSetIntentComponentWithCustomIntentWithoutComponentSet() throws Exception {
MyActivity myActivity = Robolectric.buildActivity(MyActivity.class, new Intent(Intent.ACTION_VIEW)).create().get();
assertThat(myActivity.getIntent().getAction()).isEqualTo(Intent.ACTION_VIEW);
assertThat(myActivity.getIntent().getComponent()).isEqualTo(componentName);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void onBindShouldSetIntent() throws Exception {
MyService myService = controller.create().bind().get();
assertThat(myService.boundIntent).isNotNull();
assertThat(myService.boundIntent.getComponent()).isEqualTo(componentName);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void onStartCommandShouldSetIntent() throws Exception {
MyService myService = controller.create().startCommand(3, 4).get();
assertThat(myService.startIntent).isNotNull();
assertThat(myService.startIntent.getComponent()).isEqualTo(componentName);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void onBindShouldSetIntent() throws Exception {
MyService myService = controller.create().bind().get();
assertThat(myService.boundIntent).isNotNull();
assertThat(myService.boundIntent.getComponent()).isEqualTo(componentName);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldSetIntent() throws Exception {
MyActivity myActivity = controller.create().get();
assertThat(myActivity.getIntent()).isNotNull();
assertThat(myActivity.getIntent().getComponent()).isEqualTo(componentName);
}
内容来源于网络,如有侵权,请联系作者删除!