class GetApps {
public static List<Drawable> getApps(Activity activity) {
List<Drawable> result = new ArrayList<>();
PackageManager packageManager = activity.getPackageManager();
List<ApplicationInfo> listOfAppInfo = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo applicationInfo : listOfAppInfo) {
// this is our app
if (applicationInfo.packageName.equals(activity.getPackageName())) continue;
// this is system app
if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) continue;
result.add(packageManager.getApplicationIcon(applicationInfo));
}
return result;
}
}
public class Main extends Activity {
public void main() {
//это лишь пример вызова, вызов в твоём проекте осуществляться может в любом месте, в activity!
List<Drawable> result = GetApps.getApps(this);
}
}