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);         }