Raunak Raunak - 6 months ago 38
Android Question

List of user installed apps

How do I get a list of Apps that have been installed by the user on an Android device.

I am using the following piece of code at the moment:

List<PackageInfo> packs = getPackageManager().getInstalledPackages(0);

but it returns Apps that have been installed by the both device manufacturer and me. How to I limit it so that only the apps that I installed are returned?

// Flags: See below
int flags = PackageManager.GET_META_DATA | 
            PackageManager.GET_SHARED_LIBRARY_FILES |     

PackageManager pm = getPackageManager();
List<ApplicationInfo> applications = pm.getInstalledApplications(flags);
for (ApplicationInfo appInfo : applications) {
    if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
        // System application
    } else {
        // Installed by user