Question

I want to make a list of installed and system applications. system applications means the pre-installed applications (applications which are installed at the time of manufacture). For this i categorized all the apps using (ApplicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0 - which are system apps and others are installed apps. Now my problem is i want to launch these apps on click of list items.But i could not launch system apps like Contacts,Dialer etc...

How to launch system apps programmatically or how to filter out launchable system apps?

Was it helpful?

Solution

I could not found exact answer.But i think it will helpful

List<PackageInfo> list = packageManager.getInstalledPackages(0);
for (PackageInfo pi : list) {
 try {
    ApplicationInfo appInfo = getPackageManager() .getApplicationInfo(pi.packageName, 0);
        //check whether the app is launchable or not
    if (packageManager .getLaunchIntentForPackage(appInfo.packageName) != null) {
     //check whether the app is an installed / system app
     if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
        //system apps.........
     } else {
        //installed apps............
     }
    }

   } catch (Exception e) {}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top