Android: getting a list of apps for devices - very slow

I need to get a list of all the applications installed on the device, within 5-10 seconds after the user opens my application.

This is because it takes approx. 5-10 seconds for a regular user of my Android application to request information about applications installed on the device.

To be relevant, I have to create a new copy of the list of installed applications every time my application loads.

However, using the code below, it takes more than 30 seconds on a quad-core Android device with approx. 400 applications (system and installed - I need both).

I had code executing in 'on create', but no one would wait 30 seconds to open the application. So I moved it to AsyncTask so that my application opens immediately. But still it takes +30 seconds; and if someone asks for a specific application before downloading the list, they may not receive the correct information.

Why is this code so slow? And what can I do to speed it up? I will pay gold to anyone who can do it 10 times faster or give me good advice.

final PackageManager pm = getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); for (ApplicationInfo packageInfo : packages) { InstalledAppsName.add(packageInfo.loadLabel(pm).toString()); CountApps=CountApps+1; } 
+7
source share
1 answer

See Slow Performance of LoadLabel PackageInfo

Getting a shortcut takes so long because (I think) it needs to be downloaded from the APK. At the same time, you can simply show the package names and step by step replace them with a label.

+2
source

All Articles