Does anyone know if it is possible to get an applications icon and somehow render it in a html img element in WebView?
For example, in the code below I've been able to get the installed apps and create a JSON file containing the name and package name as strings. Is there a way to get a path for the Drawable that can then be used in my WebView as the 'src' attribute for an image?
PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER);
List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, 0);
ArrayList<JSONObject> jsonAppList = new ArrayList<>();
for (ResolveInfo resolveInfo : resolveInfoList) {
JSONObject jsonApp = new JSONObject();
try {
Drawable icon = resolveInfo.activityInfo.loadIcon(packageManager);
jsonApp.put("name", resolveInfo.loadLabel(packageManager).toString());
jsonApp.put("packageName", resolveInfo.activityInfo.packageName);
jsonApp.put("icon", icon);
jsonAppList.add(jsonApp);
} catch (JSONException e) {
e.printStackTrace();
}
}