If I call
PackageManager pm = getPackageManager () ;
List<PackageInfo> pis = pm.getInstalledPackages (PackageManager.GET_PROVIDERS) ;
I get a list of installed packages, including any provivders they declare (i.e, with pis[i].providers possibly being non-null).
However, if I include PackageManager.GET_ACITIVITIES among the flags, as in
PackageManager pm = getPackageManager () ;
List<PackageInfo> pis = pm.getInstalledPackages (PackageManager.GET_ACTIVITIES | PackageManager.GET_PROVIDERS) ;
I expect to get the "same" list of installed packages, but with pis[i].activities being non-null as well. But I don't, I get an empty list.
Is there something special about including PackageManager.GET_ACTIVITES among the flags that isn't mention in the documentation?
My current work around is to leave PackageManager.GET_ACTIVITIES out of the flags, then loop through the returned list as follows:
for (PackageInfo pi : pis) {
try {
PackageInfo tmp = pm.getPackageInfo (pi.packageName, PackageManager.GET_ACTIVITIES) ;
pi.activities = tmp.activities ;
}
catch (NameNotFoundException e) {
Log.e (TAG, e.getMessage ()) ;
}
But that seems like a real kludge.
The only mention I could find of getInstalledPackages (PackageManager.GET_ACTIVITIES) returning an empty list is here, but the problem in that case seems to have been something about calling getInstalledPackages() outside the main application thread and that is not the situation in my case.
p.s. this is the .602 VZW build of Gingerbread, in case that matters