当前位置: 首页>>代码示例>>Java>>正文


Java Intent.getCategories方法代码示例

本文整理汇总了Java中android.content.Intent.getCategories方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getCategories方法的具体用法?Java Intent.getCategories怎么用?Java Intent.getCategories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.getCategories方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.content.Intent; //导入方法依赖的package包/类
@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());
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:19,代码来源:ResolverActivity.java

示例2: isLauncherAppTarget

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Returns true if the intent is a valid launch intent for a launcher activity of an app.
 * This is used to identify shortcuts which are different from the ones exposed by the
 * applications' manifest file.
 *
 * @param launchIntent The intent that will be launched when the shortcut is clicked.
 */
public static boolean isLauncherAppTarget(Intent launchIntent) {
    if (launchIntent != null
            && Intent.ACTION_MAIN.equals(launchIntent.getAction())
            && launchIntent.getComponent() != null
            && launchIntent.getCategories() != null
            && launchIntent.getCategories().size() == 1
            && launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER)
            && TextUtils.isEmpty(launchIntent.getDataString())) {
        // An app target can either have no extra or have ItemInfo.EXTRA_PROFILE.
        Bundle extras = launchIntent.getExtras();
        if (extras == null) {
            return true;
        } else {
            Set<String> keys = extras.keySet();
            return keys.size() == 1 && keys.contains(ItemInfo.EXTRA_PROFILE);
        }
    };
    return false;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:27,代码来源:Utilities.java

示例3: onCreate

import android.content.Intent; //导入方法依赖的package包/类
@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());
}
 
开发者ID:codehz,项目名称:container,代码行数:18,代码来源:ResolverActivity.java

示例4: dump

import android.content.Intent; //导入方法依赖的package包/类
public static void dump(Intent intent) {
    if (intent == null) {
        e("Intent is null");
        return;
    }

    e("Intent: action: %s", intent.getAction());

    if (intent.getPackage() != null) {
        e("  pkg: %s", intent.getPackage());
    }

    if (intent.getType() != null) {
        e("  type: %s", intent.getType());
    }

    if (intent.getComponent() != null) {
        e("  comp: %s", intent.getComponent().flattenToString());
    }

    if (intent.getDataString() != null) {
        e("  data: %s", intent.getDataString());
    }

    if (intent.getCategories() != null) {
        for (String cat : intent.getCategories()) {
            e("  cat: %s", cat);
        }
    }

    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        for (String key : bundle.keySet()) {
            Object value = bundle.get(key);
            e("  extra: %s->%s", key, value);
        }
    }

}
 
开发者ID:NamTranDev,项目名称:CleanArchitechture,代码行数:40,代码来源:Logger.java

示例5: getMessengerThreadParamsForIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * When handling an {@code Intent} from Messenger, call this to parse the parameters of the
 * intent.
 *
 * @param intent the intent of the activity
 * @return a {@link MessengerThreadParams} or null if this intent wasn't recognized as a request
 *     from Messenger to share.
 */
public static MessengerThreadParams getMessengerThreadParamsForIntent(Intent intent) {
  Set<String> categories = intent.getCategories();
  if (categories == null) {
    return null;
  }
  if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) {
    Bundle appLinkExtras = AppLinks.getAppLinkExtras(intent);
    String threadToken = appLinkExtras.getString(EXTRA_THREAD_TOKEN_KEY);
    String metadata = appLinkExtras.getString(EXTRA_METADATA);
    String participants = appLinkExtras.getString(EXTRA_PARTICIPANTS);
    boolean isReply = appLinkExtras.getBoolean(EXTRA_IS_REPLY);
    boolean isCompose = appLinkExtras.getBoolean(EXTRA_IS_COMPOSE);
    MessengerThreadParams.Origin origin = MessengerThreadParams.Origin.UNKNOWN;
    if (isReply) {
      origin = MessengerThreadParams.Origin.REPLY_FLOW;
    } else if (isCompose) {
      origin = MessengerThreadParams.Origin.COMPOSE_FLOW;
    }

    return new MessengerThreadParams(
        origin,
        threadToken,
        metadata,
        parseParticipants(participants));
  } else {
    return null;
  }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:37,代码来源:MessengerUtils.java

示例6: finishShareToMessenger

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Finishes the activity and returns the media item the user picked to Messenger.
 *
 * @param activity the activity that received the original intent from Messenger
 * @param shareToMessengerParams parameters for what to share
 */
public static void finishShareToMessenger(
    Activity activity,
    ShareToMessengerParams shareToMessengerParams) {
  Intent originalIntent = activity.getIntent();
  Set<String> categories = originalIntent.getCategories();
  if (categories == null) {
    // This shouldn't happen.
    activity.setResult(Activity.RESULT_CANCELED, null);
    activity.finish();
    return;
  }

  if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) {
    Bundle appLinkExtras = AppLinks.getAppLinkExtras(originalIntent);

    Intent resultIntent = new Intent();
    if (categories.contains(ORCA_THREAD_CATEGORY_20150314)) {
      resultIntent.putExtra(EXTRA_PROTOCOL_VERSION, MessengerUtils.PROTOCOL_VERSION_20150314);
      String threadToken = appLinkExtras.getString(MessengerUtils.EXTRA_THREAD_TOKEN_KEY);
      resultIntent.putExtra(EXTRA_THREAD_TOKEN_KEY, threadToken);
    } else {
      throw new RuntimeException(); // Can't happen.
    }
    resultIntent.setDataAndType(shareToMessengerParams.uri, shareToMessengerParams.mimeType);
    resultIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    resultIntent.putExtra(EXTRA_APP_ID, FacebookSdk.getApplicationId());
    resultIntent.putExtra(EXTRA_METADATA, shareToMessengerParams.metaData);
    resultIntent.putExtra(EXTRA_EXTERNAL_URI, shareToMessengerParams.externalUri);
    activity.setResult(Activity.RESULT_OK, resultIntent);
    activity.finish();
  } else {
    // This shouldn't happen.
    activity.setResult(Activity.RESULT_CANCELED, null);
    activity.finish();
  }
}
 
开发者ID:eviltnan,项目名称:kognitivo,代码行数:43,代码来源:MessengerUtils.java

示例7: isLauncherAppTarget

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Returns true if the intent is a valid launch intent for a launcher activity of an app.
 * This is used to identify shortcuts which are different from the ones exposed by the
 * applications' manifest file.
 *
 * @param launchIntent The intent that will be launched when the shortcut is clicked.
 */
public static boolean isLauncherAppTarget(Intent launchIntent) {
    if (launchIntent != null
            && Intent.ACTION_MAIN.equals(launchIntent.getAction())
            && launchIntent.getComponent() != null
            && launchIntent.getCategories() != null
            && launchIntent.getCategories().size() == 1
            && launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER)
            && TextUtils.isEmpty(launchIntent.getDataString())) {
        // An app target can either have no extra or have ItemInfo.EXTRA_PROFILE.
        Bundle extras = launchIntent.getExtras();
        return extras == null || extras.keySet().isEmpty();
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:22,代码来源:Utilities.java

示例8: getFastIntentCategories

import android.content.Intent; //导入方法依赖的package包/类
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()]));
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:8,代码来源:IntentResolver.java

示例9: isVrIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Whether or not the intent is a Daydream VR Intent.
 */
public boolean isVrIntent(Intent intent) {
    if (intent == null) return false;
    if (intent.getBooleanExtra(DAYDREAM_VR_EXTRA, false)) return true;
    if (intent.getCategories() != null) {
        if (intent.getCategories().contains(DAYDREAM_CATEGORY)) return true;
        if (intent.getCategories().contains(CARDBOARD_CATEGORY)) return true;
    }
    return false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:VrShellDelegate.java

示例10: getFastIntentCategories

import android.content.Intent; //导入方法依赖的package包/类
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()]));
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:8,代码来源:IntentResolver.java

示例11: testCreateEmptyQueryIntent_ValidData

import android.content.Intent; //导入方法依赖的package包/类
@Test
public void testCreateEmptyQueryIntent_ValidData() throws Exception {
    String mockCategory = "MockCategory";
    Intent result = QueryUtil.createEmptyQueryIntent(mockCategory);
    Set<String> categories = result.getCategories();
    assertEquals(1, categories.size());
    assertTrue(categories.contains(QueryUtil.BBQ_CATEGORY));
    result.getAction().equals(mockCategory);
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:10,代码来源:QueryUtilTest.java

示例12: matches

import android.content.Intent; //导入方法依赖的package包/类
@Override
public boolean matches(IntentFirewall ifw, ComponentName resolvedComponent, Intent intent,
                       int callerUid, int callerPid, String resolvedType, int receivingUid) {
    Set<String> categories = intent.getCategories();
    if (categories == null) {
        return false;
    }
    return categories.contains(mCategoryName);
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:10,代码来源:CategoryFilter.java

示例13: shouldIgnoreIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Returns true if the app should ignore a given intent.
 *
 * @param context Android Context.
 * @param intent Intent to check.
 * @return true if the intent should be ignored.
 */
public boolean shouldIgnoreIntent(Context context, Intent intent) {
    // Although not documented to, many/most methods that retrieve values from an Intent may
    // throw. Because we can't control what packages might send to us, we should catch any
    // Throwable and then fail closed (safe). This is ugly, but resolves top crashers in the
    // wild.
    try {
        // Ignore all invalid URLs, regardless of what the intent was.
        if (!intentHasValidUrl(intent)) {
            return true;
        }

        // Determine if this intent came from a trustworthy source (either Chrome or Google
        // first party applications).
        boolean isInternal = isIntentChromeOrFirstParty(intent, context);

        // "Open new incognito tab" is currently limited to Chrome or first parties.
        if (!isInternal
                && IntentUtils.safeGetBooleanExtra(
                        intent, EXTRA_OPEN_NEW_INCOGNITO_TAB, false)
                && (getPendingIncognitoUrl() == null
                        || !getPendingIncognitoUrl().equals(intent.getDataString()))) {
            return true;
        }

        // Now if we have an empty URL and the intent was ACTION_MAIN,
        // we are pretty sure it is the launcher calling us to show up.
        // We can safely ignore the screen state.
        String url = getUrlFromIntent(intent);
        if (url == null && Intent.ACTION_MAIN.equals(intent.getAction())) {
            return false;
        }

        // Ignore all intents that specify a Chrome internal scheme if they did not come from
        // a trustworthy source.
        String scheme = getSanitizedUrlScheme(url);
        if (!isInternal && scheme != null
                && (intent.hasCategory(Intent.CATEGORY_BROWSABLE)
                           || intent.hasCategory(Intent.CATEGORY_DEFAULT)
                           || intent.getCategories() == null)) {
            String lowerCaseScheme = scheme.toLowerCase(Locale.US);
            if ("chrome".equals(lowerCaseScheme) || "chrome-native".equals(lowerCaseScheme)
                    || "about".equals(lowerCaseScheme)) {
                // Allow certain "safe" internal URLs to be launched by external
                // applications.
                String lowerCaseUrl = url.toLowerCase(Locale.US);
                if ("about:blank".equals(lowerCaseUrl)
                        || "about://blank".equals(lowerCaseUrl)) {
                    return false;
                }

                Log.w(TAG, "Ignoring internal Chrome URL from untrustworthy source.");
                return true;
            }
        }

        // We must check for screen state at this point.
        // These might be slow.
        boolean internalOrVisible = isInternal || isIntentUserVisible(context);
        return !internalOrVisible;
    } catch (Throwable t) {
        return true;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:71,代码来源:IntentHandler.java

示例14: doMatchIntent

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 根据 Intent 匹配组件
 *
 * @param context    Context
 * @param intent     调用方传来的 Intent
 * @param filtersMap 插件中声明的所有组件和 IntentFilter
 * @return ComponentInfo
 */
public static String doMatchIntent(Context context, Intent intent, Map<String, List<IntentFilter>> filtersMap) {
    if (filtersMap == null) {
        return null;
    }

    final String action = intent.getAction();
    final String type = intent.resolveTypeIfNeeded(context.getContentResolver());
    final Uri data = intent.getData();
    final String scheme = intent.getScheme();
    final Set<String> categories = intent.getCategories();

    for (Map.Entry<String, List<IntentFilter>> entry : filtersMap.entrySet()) {
        String pluginName = entry.getKey();
        List<IntentFilter> filters = entry.getValue();
        if (filters == null) {
            continue;
        }

        for (IntentFilter filter : filters) {
            int match = filter.match(action, type, scheme, data, categories, "ComponentList");
            if (match >= 0) {
                if (LOG) {
                    LogDebug.d(TAG, "IntentFilter 匹配成功: " + entry.getKey());
                }
                return pluginName;
            } else {
                if (LOG) {
                    String reason;
                    switch (match) {
                        case IntentFilter.NO_MATCH_ACTION:
                            reason = "action";
                            break;
                        case IntentFilter.NO_MATCH_CATEGORY:
                            reason = "category";
                            break;
                        case IntentFilter.NO_MATCH_DATA:
                            reason = "data";
                            break;
                        case IntentFilter.NO_MATCH_TYPE:
                            reason = "type";
                            break;
                        default:
                            reason = "unknown reason";
                            break;
                    }
                    LogDebug.d(TAG, "  Filter did not match: " + reason);
                }
            }
        }
    }
    return "";
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:61,代码来源:IntentMatcherHelper.java


注:本文中的android.content.Intent.getCategories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。