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:
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.