PackageManager, packagemanager

Source: Internet
Author: User

PackageManager, packagemanager
I. Functions of PackageManager

1. Install and uninstall the application.
2. query permission information.
3. query Application-related information (application, activity, Cycler, service, provider, and related attributes ).
4. query the installed applications.
5. add and delete permission.
6. Clear user data, cache, and code segments.

Ii. PackageManager class

1. public abstract PackageManager getPackageManager ()
Function: obtain a PackageManager object.

2. public abstract Drawable getApplicationIcon (String packageName)
Parameter: packageName package name.
Function: returns the icon of the given package name. Otherwise, null is returned.

3. public abstract ApplicationInfo getApplicationInfo (String packageName, int flags)
Parameter: packageName package name flags the ApplicationInfo is the flags mark, which can be directly assigned to the constant 0.
Function: returns the ApplicationInfo object.

4. public abstract List <ApplicationInfo> getInstalledApplications (int flags)
Parameter: flag is generally GET_UNINSTALLED_PACKAGES, then all ApplicationInfo is returned. You can filter the flag of ApplicationInfo to obtain the desired one.
Function: returns all PackageInfo for a given condition.

5. public abstract ResolveInfo resolveActivity (Intent intent, int flag)
Parameter: intent query condition, which is the action and categry configured by the Activity.
Flag: MATCH_DEFAULT_ONLY: Category must contain the Activity of CATEGORY_DEFAULT.
GET_INTENT_FILTERS: match the Intent condition.
GET_RESOLVED_FILTER: match the Intent condition.
Function: returns the ResolveInfo object for a given condition (essentially Activity ).

Public abstract List <ResolveInfo> queryIntentServices (Intent intent, int flags)
Parameter: Same as resolveActivity.
Function: returns all ResolveInfo objects (essentially services) of a given condition and collection objects.

Iii. PackageItemInfo class

Note: base classes of all nodes in the AndroidManifest. xml file provide basic information about these nodes: label, icon, and meta-data. Instead of directly using it, it inherits from the subclass and then calls the corresponding method.

Iv. PackageInfo class

Note: You can manually obtain information about the AndroidManifest. xml file.
Common fields:
Public String packageName package name.
Public ActivityInfo [] All <activity> node information of activities.
Public ApplicationInfo applicationInfo <application> indicates only one node.
Public ActivityInfo [] receivers all <worker ER> node information, multiple.
Public ServiceInfo [] services all <service> node information, multiple.

5. ApplicationInfo class inherited from PackageItemInfo

Description: obtains information about <application> nodes in a specified reference program.
Field description:
Flags field: FLAG_SYSTEM system application.
FLAG_EXTERNAL_STOTAGE indicates that the application is installed in sdcard.
Common Methods inherit from loadIcon () and loadLabel () in the PackageItemInfo class ().

6. The ActivityInfo class inherits from the PackageItemInfo class.

Description: obtains information about <activity/> or <worker ER/> nodes in an application. You can use it to obtain any set attributes, including theme and launchMode.
Common Methods inherit from loadIcon () and loadLabel () in the PackageItemInfo class ().

VII. ServiceInfo class

Note: similar to ActivityInfo, it also inherits from PackageItemInfo, but it represents <service> node information.

VIII. ResolveInfo class

Note: You can obtain information about the last-level directories Based on the <intent> node, which is usually the <activity>, <worker ER>, and <service> node information.
Commonly used methods include loadIcon (PackageManager pm) and loadLabel (PackageManager pm ).

 

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.