如果你想创建自定义启动器然后 -
将安装应用程序列表,将gridView或ListView带到您要显示应用程序的任何位置,创建自定义适配器以将图标和名称显示到ListView
获取已安装应用列表-
PackageManager pm = getPackageManager();
List<ApplicationInfo> installedApps = context.getPackageManager()
.getInstalledApplications(PackageManager.PERMISSION_GRANTED);
for (ApplicationInfo apps : installedApps) {
if (context.getPackageManager().getLaunchIntentForPackage(apps.packageName) != null) {
//for app Name
appList.add((String)pm.getApplicationLabel(apps).toString());
//For app Package Name
appPackage.add(apps.packageName); //appList and appPackage is arraylist
}
}
用于创建图标
Drawable icon = getPackageManager().getApplicationIcon("Your.Package.Name");
如果你想将图标用作位图,请将此可绘制对象更改为位图。
为了启动应用程序使用 Intent 和 Package Manager-
PackageManager pm = getPackageManager();
Intent appStartIntent = pm.getLaunchIntentForPackage("Your.Package.Name");
if (appStartIntent != null) {
startActivity(appStartIntent);
}