Packagemanager related
This API is an encapsulation of all data structures based on loading information, including the following features:
Install, uninstall application query permission Related Information
Query application related information (application,activity,receiver,service,provider and corresponding attributes, etc.)
Querying installed Apps
Add, remove permission
Clear user data, cache, code snippets, etc.
/** * Packagemanager: * This API is an encapsulation of all data structures based on loading information, including the following features: * Install, uninstall application query permission related information query application related * information (APPLICATION,AC Tivity,receiver,service,provider and corresponding attributes, etc.) * Query installed apps Add, remove permission clear user data, cache, code snippets and other non-query related APIs require specific permissions. * Mainly includes information about the app packages installed on the current device * For example: Get information on Installed applications */private hashmap<string, string> installpackagesinfo () {// Gets the Packagemanager object Packagemanager Packagemanager = This.getpackagemanager ();/*getinstalledapplications Returns the collection of app packages installed on the current device * ApplicationInfo corresponding to the application label in Androidmanifest.xml. It is able to obtain the corresponding information of the application */list<applicationinfo> Applicationinfos = Packagemanager.getinstalledapplications ( 0); hashmap<string, string> resultmap = new hashmap<string, string> ();iterator<applicationinfo> iterator = Applicationinfos.iterator (); while (Iterator.hasnext ()) {ApplicationInfo applicationinfo = Iterator.next (); String packagename = applicationinfo.packagename;//Package name string Packagelabel = Packagemanager.getapplicationlabel ( ApplicationInfo). toString ();//Get LabelresuLtmap.put (Packagelabel, PackageName);} return resultmap;}
In addition to the Packagemanager class, we have found several very interesting methods.
Xmlresourceparse getXml (String packagename,int resid,applicationinfo AppInfo) is able to load an XML file from the specified package.
Android Packagemanager Simple Introduction