Packagemanager Problems
This class of API is an encapsulation of all data structures based on information loading, including the following functions:
Install and uninstall an application to query permission information
Query application-related information (application, activity, Cycler, service, provider, and related attributes)
Query installed applications
Add and delete permission
Clear user data, cache, code segments, etc.
/** <Br/> * packagemanager Introduction: <br/> * this type of API encapsulates all data structures based on loading information, including the following functions: <br/> * install and uninstall an application. query permission information and query application information. <br/> * Information (application, activity, Cycler, service, provider, and related attributes) <br/> * added query installed applications. Deleting permission requires specific permissions to clear user data, caches, code segments, and other non-query-related APIs. <Br/> * contains the following information about the application package installed on the current device: <br/>: obtain information about the installed application <br/> */<br/> private hashmap <string, string> installpackagesinfo () {<br/> // obtain the packagemanager object <br/> packagemanager = This. getpackagemanager (); <br/>/* getinstalledapplications return the set of application packages installed on the current device <br/> * applicationinfo corresponds to androidmanifest. the application tag in XML. You can obtain information about the application <br/> */<br/> List <applicationinfo> applicationinfos = packagemanager. getinstalledapplications (0); <br/> hashmap <string, string> resultmap = new hashmap <string, string> (); <br/> iterator <applicationinfo> iterator = applicationinfos. iterator (); <br/> while (iterator. hasnext () {<br/> applicationinfo = iterator. next (); <br/> string packagename = applicationinfo. packagename; // package name <br/> string packagelabel = packagemanager. getapplicationlabel (applicationinfo ). tostring (); // obtain the label <br/> resultmap. put (packagelabel, packagename); <br/>}</P> <p> return resultmap; </P> <p>}
In addition, we found several interesting methods in the packagemanager class.
Xmlresourceparse getxml (string packagename, int resid, applicationinfo appinfo) can load an XML file from a specified package.