Android PackageManager:queryIntentActivities
Posted 好久不见
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android PackageManager:queryIntentActivities相关的知识,希望对你有一定的参考价值。
Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.setPackage(getPackageName()); intent.addCategory(Intent.CATEGORY_SAMPLE_CODE); PackageManager pm = getPackageManager(); List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0); ArrayList<SampleInfo> samples = new ArrayList<SampleInfo>(); final int count = infos.size(); for (int i = 0; i < count; i++) { final ResolveInfo info = infos.get(i); final CharSequence labelSeq = info.loadLabel(pm); String label = labelSeq != null ? labelSeq.toString() : info.activityInfo.name; Intent target = new Intent(); target.setClassName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name); SampleInfo sample = new SampleInfo(label, target); samples.add(sample); }
以上是关于Android PackageManager:queryIntentActivities的主要内容,如果未能解决你的问题,请参考以下文章
Android:PackageManager.getSystemAvailableFeatures() 在 Nexus9 上没有按预期工作
使用 loadLabel(android.content.pm.PackageManager) 为 Android Widget 设置标签的示例