本文整理了Java中android.content.Intent.getCategories()
方法的一些代码示例,展示了Intent.getCategories()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getCategories()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getCategories
暂无
代码示例来源:origin: android-hacker/VirtualXposed
private static FastImmutableArraySet<String> getFastIntentCategories(Intent intent) {
final Set<String> categories = intent.getCategories();
if (categories == null) {
return null;
}
return new FastImmutableArraySet<String>(categories.toArray(new String[categories.size()]));
}
代码示例来源:origin: robolectric/robolectric
private static int matchIntentFilter(Intent intent, IntentFilter intentFilter) {
return intentFilter.match(
intent.getAction(),
intent.getType(),
intent.getScheme(),
intent.getData(),
intent.getCategories(),
TAG);
}
代码示例来源:origin: android-hacker/VirtualXposed
@Override
public boolean activitySupportsIntent(ComponentName component, Intent intent, String resolvedType) {
synchronized (mPackages) {
VPackage.ActivityComponent a = mActivities.mActivities.get(component);
if (a == null) {
return false;
}
for (int i = 0; i < a.intents.size(); i++) {
if (a.intents.get(i).filter.match(intent.getAction(), resolvedType, intent.getScheme(), intent.getData(),
intent.getCategories(), TAG) >= 0) {
return true;
}
}
return false;
}
}
代码示例来源:origin: android-hacker/VirtualXposed
@SuppressLint("MissingSuperCall")
@Override
protected void onCreate(Bundle savedInstanceState) {
final int titleResource;
final Intent intent = makeMyIntent();
final Set<String> categories = intent.getCategories();
if (Intent.ACTION_MAIN.equals(intent.getAction())
&& categories != null
&& categories.size() == 1
&& categories.contains(Intent.CATEGORY_HOME)) {
titleResource = R.string.choose;
} else {
titleResource = R.string.choose;
}
onCreate(savedInstanceState, intent, getResources().getText(titleResource),
null, null, true, VUserHandle.getCallingUserId());
}
代码示例来源:origin: facebook/facebook-android-sdk
Set<String> categories = intent.getCategories();
if (categories == null) {
return null;
代码示例来源:origin: facebook/facebook-android-sdk
ShareToMessengerParams shareToMessengerParams) {
Intent originalIntent = activity.getIntent();
Set<String> categories = originalIntent.getCategories();
if (categories == null) {
代码示例来源:origin: robolectric/robolectric
Set<String> categories1 = i1.getCategories();
Set<String> categories2 = i2.getCategories();
if (categories1 == null) return categories2 == null ? 0 : -1;
if (categories2 == null) return 1;
代码示例来源:origin: Tencent/tinker
final IntentFilter intentFilter = item.getValue();
final int matchRes = intentFilter.match(intent.getAction(), intent.getType(),
intent.getScheme(), intent.getData(), intent.getCategories(), TAG);
final boolean matches = (matchRes != IntentFilter.NO_MATCH_ACTION)
&& (matchRes != IntentFilter.NO_MATCH_CATEGORY)
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldAddCategories() throws Exception {
Intent intent = new Intent();
Intent self = intent.addCategory("foo");
assertTrue(intent.getCategories().contains("foo"));
assertSame(self, intent);
}
代码示例来源:origin: elvishew/xLog
first = false;
Set<String> mCategories = intent.getCategories();
if (mCategories != null) {
if (!first) {
代码示例来源:origin: android-hacker/VirtualXposed
return false;
if (!ObjectsCompat.equals(a.getCategories(), b.getCategories())) {
return false;
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldFillIn() throws Exception {
Intent intentA = new Intent();
Intent intentB = new Intent();
intentB.setAction("foo");
Uri uri = Uri.parse("http://www.foo.com");
intentB.setDataAndType(uri, "text/html");
String category = "category";
intentB.addCategory(category);
intentB.setPackage("com.foobar.app");
ComponentName cn = new ComponentName("com.foobar.app", "fragmentActivity");
intentB.setComponent(cn);
intentB.putExtra("FOO", 23);
int flags = Intent.FILL_IN_ACTION |
Intent.FILL_IN_DATA |
Intent.FILL_IN_CATEGORIES |
Intent.FILL_IN_PACKAGE |
Intent.FILL_IN_COMPONENT;
int result = intentA.fillIn(intentB, flags);
assertEquals("foo", intentA.getAction());
assertSame(uri, intentA.getData());
assertEquals("text/html", intentA.getType());
assertTrue(intentA.getCategories().contains(category));
assertEquals("com.foobar.app", intentA.getPackage());
assertSame(cn, intentA.getComponent());
assertEquals(23, intentA.getIntExtra("FOO", -1));
assertEquals(result, flags);
}
代码示例来源:origin: android-hacker/VirtualXposed
filter.addAction(intent.getAction());
Set<String> categories = intent.getCategories();
if (categories != null) {
for (String cat : categories) {
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldSupportCategories() throws Exception {
Intent intent = new Intent();
Intent self = intent.addCategory("category.name.1");
intent.addCategory("category.name.2");
assertTrue(intent.hasCategory("category.name.1"));
assertTrue(intent.hasCategory("category.name.2"));
Set<String> categories = intent.getCategories();
assertTrue(categories.contains("category.name.1"));
assertTrue(categories.contains("category.name.2"));
intent.removeCategory("category.name.1");
assertFalse(intent.hasCategory("category.name.1"));
assertTrue(intent.hasCategory("category.name.2"));
intent.removeCategory("category.name.2");
assertFalse(intent.hasCategory("category.name.2"));
assertThat(intent.getCategories()).isNull();
assertSame(self, intent);
}
代码示例来源:origin: limpoxe/Android-Plugin-Framework
private static ArrayList<String> findClassNameByIntent(Intent intent, HashMap<String, ArrayList<PluginIntentFilter>> intentFilter) {
if (intentFilter != null) {
ArrayList<String> targetClassNameList = null;
Iterator<Map.Entry<String, ArrayList<PluginIntentFilter>>> entry = intentFilter.entrySet().iterator();
while (entry.hasNext()) {
Map.Entry<String, ArrayList<PluginIntentFilter>> item = entry.next();
Iterator<PluginIntentFilter> values = item.getValue().iterator();
while (values.hasNext()) {
PluginIntentFilter filter = values.next();
int result = filter.match(intent.getAction(), intent.getType(), intent.getScheme(),
intent.getData(), intent.getCategories());
if (result != PluginIntentFilter.NO_MATCH_ACTION
&& result != PluginIntentFilter.NO_MATCH_CATEGORY
&& result != PluginIntentFilter.NO_MATCH_DATA
&& result != PluginIntentFilter.NO_MATCH_TYPE) {
if (targetClassNameList == null) {
targetClassNameList = new ArrayList<String>();
}
targetClassNameList.add(item.getKey());
}
}
}
return targetClassNameList;
}
return null;
}
代码示例来源:origin: Neamar/KISS
if (intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(intent.getAction())) {
代码示例来源:origin: limpoxe/Android-Plugin-Framework
/**
* Test whether this filter matches the given <var>intent</var>.
*
* @param intent The Intent to compare against.
* @param resolve If true, the intent's type will be resolved by calling
* Intent.resolveType(); otherwise a simple match against
* Intent.type will be performed.
* @param logTag Tag to use in debugging messages.
*
* @return Returns either a valid match constant (a combination of
* {@link #MATCH_CATEGORY_MASK} and {@link #MATCH_ADJUSTMENT_MASK}),
* or one of the error codes {@link #NO_MATCH_TYPE} if the type didn't match,
* {@link #NO_MATCH_DATA} if the scheme/path didn't match,
* {@link #NO_MATCH_ACTION if the action didn't match, or
* {@link #NO_MATCH_CATEGORY} if one or more categories didn't match.
*
* @return How well the filter matches. Negative if it doesn't match,
* zero or positive positive value if it does with a higher
* value representing a better match.
*
* @see #match(String, String, String, android.net.Uri , Set, String)
*/
public final int match(ContentResolver resolver, Intent intent,
boolean resolve, String logTag) {
String type = resolve ? intent.resolveType(resolver) : intent.getType();
return match(intent.getAction(), type, intent.getScheme(),
intent.getData(), intent.getCategories());
}
代码示例来源:origin: limpoxe/Android-Plugin-Framework
Set<String> category = intent.getCategories();
if (category != null) {
Iterator<String> itr = category.iterator();
代码示例来源:origin: ximsfei/Android-plugin-support
private static FastImmutableArraySet<String> getFastIntentCategories(Intent intent) {
final Set<String> categories = intent.getCategories();
if (categories == null) {
return null;
}
return new FastImmutableArraySet<String>(categories.toArray(new String[categories.size()]));
}
代码示例来源:origin: OneDrive/onedrive-picker-android
/**
* Make sure that the given intent matches the expected signature for the
* action Saver
*/
private void verifyOneDriveGetContentActivity(final Intent intent) {
assertEquals(ONEDRIVE_INTENT_ACTION_SAVER, intent.getAction());
assertEquals(Intent.CATEGORY_DEFAULT, intent.getCategories().iterator().next());
}
内容来源于网络,如有侵权,请联系作者删除!