In my application I use the following method to get the list of apps installed in the system.
packageManager.getInstalledPackages(0);
Due to this sometimes the following exception occurred-
AndroidRuntime: java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 526696 bytes
To avoid this I have modified the code as below,
List<ApplicationInfo> applicationInfoList = packageManager.getInstalledApplications(PackageManager.GET_META_DATA);
Could you please help to understand the following points?
- Does usage of getInstalledApplications() instead of getInstalledPackages() helps to reduce the size of received size?
- What does the flag PackageManager.GET_META_DATA filter here? The definition from Android document is NOT clear to me-“Additional meta-data associated with this component. This field will only be filled in if you set the PackageManager#GET_META_DATA flag when requesting the info.”
I am guessing that these questions stem from your earlier question, which I marked as a duplicate of this 10-year-old question.
Does usage of getInstalledApplications() instead of getInstalledPackages() helps to reduce the size of received size?
There should be fewer applications than packages, as “packages” could include some pre-installed items that do not qualify as “applications”. This may not make a huge difference, but it might help.
What does the flag PackageManager.GET_META_DATA filter here?
In the context of getInstalledApplications()
, including GET_META_DATA
will return the details of any <meta-data>
elements inside the <application>
element in the manifests of those applications. Unless you need this information, I recommend not including this flag.
More generally, you need to determine what it is that you are trying to accomplish, then identify the best PackageManager
methods to return you the least information that let you accomplish your aims.
5