On Android, there is a common solution to get the list of apps using:
PackageManager pm=getPackageManager();
List<ApplicationInfo> packages=pm.getInstalledApplications(PackageManager.GET_META_DATA)
After this query, some of the ApplicationInfo objects get their field "metadata" being filled with stuff.
My question is simple:
What is the purpose of this field?
When should we use it, and do we really need it ?
Also, what is the meaning of just using 0 as the flags? will it get all of the apps?
What is the purpose of this field?
To give you the metadata for the component, as specified by <meta-data>
elements in the manifest.
When should we use it
When you want to access the contents of the <meta-data>
elements.
do we really need it ?
If you have <meta-data>
elements, yes. Otherwise, no.
what is the meaning of just using 0 as the flags? will it get all of the apps?
It always gets "all of the apps". What the flags control is what data about those apps it retrieves. I assume this is to minimize the amount of data transferred over IPC in response to these calls, but that's just an educated guess.