Android Packagemanager Simple Introduction

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.