Get the name, icon and package name of all the installed applications in android
Solution 1
Please use the below code and directions:
//check this code with some hard work then you will rock
List<PackageInfo> apps = getPackageManager().getInstalledPackages(0);
ArrayList<AppInfo> res = new ArrayList<AppInfo>();
for(int i=0;i<apps.size();i++) {
PackageInfo p = apps.get(i);
AppInfo newInfo = new AppInfo();
newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString();
newInfo.pname = p.packageName;
newInfo.versionName = p.versionName;
newInfo.versionCode = p.versionCode;
newInfo.icon = p.applicationInfo.loadIcon(getPackageManager());
res.add(newInfo);
}
}
class AppInfo {
String appname = "";
String pname = "";
String versionName = "";
int versionCode = 0;
Drawable icon;
}
For more information try these links: http://javatechig.com/android/how-to-get-list-of-installed-apps-in-android http://developer.android.com/reference/android/content/pm/PackageManager.html
Solution 2
Using this link from this question. I got the package name. Then using the answer from this question I got the package/app icon. Now as soon as I figure the array adapter to accommodate this. I guess its done then.
My Code:
final PackageManager pm = getPackageManager();
List<applicationinfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
//The log is not required so if you want to and I recommend during release you remove that statement.
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Drawable icon = getPackageManager().getApplicationIcon(packageInfo.packageName)
imageView.setImageDrawable(icon);
Hope this helps all readers as well.
Solution 3
get appliction icon image from package name
Drawable appicon = getPackageManager().getApplicationIcon("com.example.pkgname");
img.setImageDrawable(appicon);
KISHORE_ZE
Updated on June 14, 2022Comments
-
KISHORE_ZE almost 2 years
I want to be able to get the string package name and icon of all the applications installed in my phone. What I have done: Browsed and found this solution
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List pkgAppsList = this.getPackageManager().queryIntentActivities(mainIntent, 0); for(int counter = 0; counter<=pkgAppsList.size()-1;counter++) { Log.e("TAG", pkgAppsList.get(counter).toString()); }
The problem is that it displays package and class name as as a as a mix and I can't get the icon. What I want is to show the user a list of all the applications installed on the phone with the icon. And I also need to be able to get the package name with a
List.OnItemClickListener
. I assume that using an array of app names and package name which are of same positioning I can do that. But how would I get the app icon and name with package name. Preferably as an Array or ArrayList that I can convert into a listView object. If there is any alternative method even let me know. I am still a beginner in Android.And please do help.
-
KISHORE_ZE over 8 yearsThanks Androider. I'll try it and let you know.
-
KISHORE_ZE over 8 yearsJust give some time. It's getting pretty late here. Will let you know tomorrow
-
Androider over 8 yearsNo problems, do as you comforts.
-
KISHORE_ZE over 8 yearsI have a small problem. It gives me an error Activity must contain
android.R.id.list
and I practically copy pasted all of that code -
Androider over 8 yearsThis is the way to achieve, you can also use link: javatechig.com/android/…
-
KISHORE_ZE over 8 yearsOk, maybe it could be my mistake. I'll try it all over again. Unfortunately I won't be having Android Studio right now. I am out of station. And it could even be because of the AIDE mobile developing app I'm using. I'll keep trying in AIDE. But if it doesn't work I'll try it in Android Studio once I get back. Sorry for the delay.
-
KISHORE_ZE over 8 yearsHey, I guess this should answer my question. What with the website and all. But I am guessing my mistake is with the ListAdapter somewhere. But I found another solution, which does not solve the question completely. But at least to some extent. See my answer below.
-
Androider over 8 yearsLet us continue this discussion in chat.
-
Jarin Rocks about 5 yearshow can I get only the apps installed by the user not the system apps