码迷,mamicode.com
首页 > 移动开发 > 详细

Android PackageManager:queryIntentActivities

时间:2017-09-24 13:40:32      阅读:476      评论:0      收藏:0      [点我收藏+]

标签:new   pre   ++   classname   get   color   style   add   load   

        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

标签:new   pre   ++   classname   get   color   style   add   load   

原文地址:http://www.cnblogs.com/onelikeone/p/7586961.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!