1.直接上代码~
private void loadApps() {
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> apps = getPackageManager().queryIntentActivities(intent, 0);
//for循环遍历ResolveInfo对象获取包名和类名
for (int i = 0; i < apps.size(); i++) {
ResolveInfo info = apps.get(i);
String packageName = info.activityInfo.packageName;
CharSequence cls = info.activityInfo.name;
CharSequence name = info.activityInfo.loadLabel(getPackageManager());
Log.e("!!!!!", name + "----" + packageName + "----" + cls);
}
}
2.效果图~
应用包名效果图.png
网友评论