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


Java Intent.resolveTypeIfNeeded方法代码示例

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


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

示例1: startIntentSenderForResultInner

import android.content.Intent; //导入方法依赖的package包/类
private void startIntentSenderForResultInner(IntentSender intent, String who, int requestCode,
                                             Intent fillInIntent, int flagsMask, int flagsValues,
                                             Bundle options)
        throws IntentSender.SendIntentException {
    try {
        String resolvedType = null;
        if (fillInIntent != null) {
            fillInIntent.migrateExtraStreamToClipData();
            fillInIntent.prepareToLeaveProcess(this);
            resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
        }
        int result = ActivityManagerNative.getDefault()
                .startActivityIntentSender(mMainThread.getApplicationThread(), intent,
                        fillInIntent, resolvedType, mToken, who,
                        requestCode, flagsMask, flagsValues, options);
        if (result == ActivityManager.START_CANCELED) {
            throw new IntentSender.SendIntentException();
        }
        Instrumentation.checkStartActivityResult(result, null);
    } catch (RemoteException e) {
    }
    if (requestCode >= 0) {
        // If this start is requesting a result, we can avoid making
        // the activity visible until the result is received.  Setting
        // this code during onCreate(Bundle savedInstanceState) or onResume() will keep the
        // activity hidden during this time, to avoid flickering.
        // This can only be done when a result is requested because
        // that guarantees we will get information back when the
        // activity is finished, no matter what happens to it.
        mStartedActivity = true;
    }
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:33,代码来源:a.java

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