Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PackageInfo LoadLabel slow performance

I am coding an app for Android, where getting a label (actual name) of the application is extremelly slow. Particularly this code is performing really badly:

packageInfo.loadLabel(pm);

Just to give you some metrics. On an Android device with 400 installed applications, it'll take less than a second to build a list of all application packagenames (com.android.*, etc..). However, it'll take over 30 seconds to get an actual name for each of the apps.

I've tried this code as well, but it's pretty much the same result (very slow):

(String)pm.getApplicationLabel(packageInfo);

Question: If application packagename is known (i.e. "com.android.htmlviewer"), is there an alternative way to grab an application name (i.e. "HTML Viewer") quickly?

like image 749
jjj Avatar asked Nov 12 '22 16:11

jjj


1 Answers

You could build a database in your app of "known" application names, and update it every time your app comes across a new package. The first run through will take a while, but after that you could save a lot of time by only checking one or two package names.

like image 139
rgrasell Avatar answered Nov 15 '22 07:11

rgrasell