| java.lang.Object | ||
| android.content.pm.PackageManager | ||
Class for retrieving various kinds of information related to the application packages that are currently installed on the device. You can find this class through getPackageManager().
Nested Classes| PackageManager.NameNotFoundException | This exception is thrown when a given package, application, or component name can not be found. |
| Value | ||||
|---|---|---|---|---|
| int | COMPONENT_ENABLED_STATE_DEFAULT | 0 | 0x00000000 | |
| int | COMPONENT_ENABLED_STATE_DISABLED | 2 | 0x00000002 | |
| int | COMPONENT_ENABLED_STATE_ENABLED | 1 | 0x00000001 | |
| int | GET_ACTIVITIES | PackageInfo flag: return information about activities in the package in activities. | 1 | 0x00000001 |
| int | GET_INSTRUMENTATION | PackageInfo flag: return information about instrumentation in the package in instrumentation. | 16 | 0x00000010 |
| int | GET_INTENT_FILTERS | PackageInfo flag: return information about the intent filters supported by the activity. | 32 | 0x00000020 |
| int | GET_META_DATA | ComponentInfo flag: return the metaData data Bundle that is associated with a component. | 128 | 0x00000080 |
| int | GET_PROVIDERS | PackageInfo flag: return information about content providers in the package in providers. | 8 | 0x00000008 |
| int | GET_RECEIVERS | PackageInfo flag: return information about intent receivers in the package in receivers. | 2 | 0x00000002 |
| int | GET_RESOLVED_FILTER | ResolveInfo flag: return the IntentFilter that was matched for a particular ResolveInfo in filter. | 64 | 0x00000040 |
| int | GET_SERVICES | PackageInfo flag: return information about services in the package in services. | 4 | 0x00000004 |
| int | INCLUDE_DISABLED_COMPONENTS | {@link PackageInfo) flag: include disabled components in the returned info. | 256 | 0x00000100 |
| int | MATCH_DEFAULT_ONLY | Resolution and querying flag: if set, only filters that support the DEFAULT_CATEGORY will be considered for matching. | 65536 | 0x00010000 |
| int | PERMISSION_DENIED | Permission check result: this is returned by checkPermission(String, String) if the permission has not been granted to the given package. | -1 | 0xffffffff |
| int | PERMISSION_GRANTED | Permission check result: this is returned by checkPermission(String, String) if the permission has been granted to the given package. | 0 | 0x00000000 |
| int | SIGNATURE_FIRST_NOT_SIGNED | Signature check result: this is returned by checkSignatures(String, String) if the first package is not signed, but the second is. | -1 | 0xffffffff |
| int | SIGNATURE_MATCH | Signature check result: this is returned by checkSignatures(String, String) if the two packages have a matching signature. | 0 | 0x00000000 |
| int | SIGNATURE_NEITHER_SIGNED | Signature check result: this is returned by checkSignatures(String, String) if neither of the two packages is signed. | 1 | 0x00000001 |
| int | SIGNATURE_NO_MATCH | Signature check result: this is returned by checkSignatures(String, String) if both packages are signed but there is no matching signature. | -3 | 0xfffffffd |
| int | SIGNATURE_SECOND_NOT_SIGNED | Signature check result: this is returned by checkSignatures(String, String) if the second package is not signed, but the first is. | -2 | 0xfffffffe |
| int | SIGNATURE_UNKNOWN_PACKAGE | Signature check result: this is returned by checkSignatures(String, String) if either of the given package names are not valid. | -4 | 0xfffffffc |
| PackageManager() |
| abstract | void | addPackageToPreferred(String packageName) | |||
| Add a new package to the list of preferred packages. | |||||
| abstract | int | checkPermission(String permName, String pkgName) | |||
| Check whether a particular package has been granted a particular permission. | |||||
| abstract | int | checkSignatures(String pkg1, String pkg2) | |||
| Compare the signatures of two packages to determine if the same signature appears in both of them. | |||||
| abstract | Drawable | getActivityIcon(ComponentName activityName) | |||
| Retrieve the icon associated with an activity. | |||||
| abstract | Drawable | getActivityIcon(Intent intent) | |||
| Retrieve the icon associated with an Intent. | |||||
| abstract | ActivityInfo | getActivityInfo(ComponentName className, int flags) | |||
| Retrieve all of the information we know about a particular activity class. | |||||
| abstract | Drawable | getApplicationIcon(String packageName) | |||
| Retrieve the icon associated with an application. | |||||
| abstract | Drawable | getApplicationIcon(ApplicationInfo info) | |||
| Retrieve the icon associated with an application. | |||||
| abstract | ApplicationInfo | getApplicationInfo(String packageName, int flags) | |||
| Retrieve all of the information we know about a particular package/application. | |||||
| abstract | CharSequence | getApplicationLabel(ApplicationInfo info) | |||
| Return the label to use for this application. | |||||
| abstract | Drawable | getDefaultActivityIcon() | |||
| Return the generic icon for an activity that is used when no specific icon is defined. | |||||
| abstract | Drawable | getDrawable(String packageName, int resid, ApplicationInfo appInfo) | |||
| Retrieve an image from a package. | |||||
| abstract | List | getInstalledApplications(int flags) | |||
| Return a List of all application packages that are installed on the device. | |||||
| abstract | List | getInstalledPackages(int flags) | |||
| Return a List of all packages that are installed on the device. | |||||
| abstract | InstrumentationInfo | getInstrumentationInfo(ComponentName className, int flags) | |||
| Retrieve all of the information we know about a particular instrumentation class. | |||||
| abstract | String | getNameForUid(int uid) | |||
| Retrieve the official name associated with a user id. | |||||
| PackageInfo | getPackageArchiveInfo(String archiveFilePath, int flags) | ||||
| Retrieve overall information about an application package defined in a package archive file | |||||
| abstract | PackageInfo | getPackageInfo(String packageName, int flags) | |||
| Retrieve overall information about an application package that is installed on the system. | |||||
| abstract | String[] | getPackagesForUid(int uid) | |||
| Retrieve the names of all packages that are associated with a particular user id. | |||||
| abstract | PermissionInfo | getPermissionInfo(String name, int flags) | |||
| Retrieve all of the information we know about a particular permission. | |||||
| abstract | List | getPreferredPackages(int flags) | |||
| Retrieve the list of all currently configured preferred packages. | |||||
| abstract | ActivityInfo | getReceiverInfo(ComponentName className, int flags) | |||
| Retrieve all of the information we know about a particular receiver class. | |||||
| abstract | Resources | getResourcesForActivity(ComponentName activityName) | |||
| Retrieve the resources associated with an activity. | |||||
| abstract | Resources | getResourcesForApplication(ApplicationInfo app) | |||
| Retrieve the resources for an application. | |||||
| abstract | Resources | getResourcesForApplication(String appPackageName) | |||
| Retrieve the resources associated with an application. | |||||
| abstract | ServiceInfo | getServiceInfo(ComponentName className, int flags) | |||
| Retrieve all of the information we know about a particular service class. | |||||
| abstract | CharSequence | getText(String packageName, int resid, ApplicationInfo appInfo) | |||
| Retrieve text from a package. | |||||
| abstract | XmlPullParser | getXml(String packageName, int resid, ApplicationInfo appInfo) | |||
| Retrieve an XML file from a package. | |||||
| void | installPackage(Uri packageURI) | ||||
| Install a package. | |||||
| abstract | List | queryContentProviders(String processName, int flags) | |||
| Retrieve content provider information. | |||||
| abstract | List | queryInstrumentation(String targetPackage, int flags) | |||
| Retrieve information about available instrumentation code. | |||||
| abstract | List | queryIntentActivities(Intent intent, int flags) | |||
| Retrieve all activities that can be performed for the given intent. | |||||
| abstract | List | queryIntentActivityOptions(ComponentName caller, Intent[] specifics, Intent intent, int flags) | |||
| Retrieve a set of activities that should be presented to the user as similar options. | |||||
| abstract | List | queryIntentReceivers(Intent intent, int flags) | |||
| Retrieve all receivers that can handle a broadcast of the given intent. | |||||
| abstract | List | queryIntentServices(Intent intent, int flags) | |||
| Retrieve all services that can match the given intent. | |||||
| abstract | void | removePackageFromPreferred(String packageName) | |||
| Remove a package from the list of preferred packages. | |||||
| abstract | ResolveInfo | resolveActivity(Intent intent, int flags) | |||
| Determine the best action to perform for a given Intent. | |||||
| abstract | ProviderInfo | resolveContentProvider(String name, int flags) | |||
| Find a single content provider by its base path name. | |||||
| abstract | ResolveInfo | resolveService(Intent intent, int flags) | |||
| Determine the best service to handle for a given Intent. | |||||
| abstract | void | setApplicationEnabledSetting(String packageName, int newState) | |||
| Set the enabled setting for an application This setting will override any enabled state which may have been set by the application in its manifest. | |||||
| abstract | void | setComponentEnabledSetting(ComponentName componentName, int newState) | |||
| Set the enabled setting for a package component (activity, receiver, service, provider). | |||||
Methods inherited
from class
java.lang.Object
| packageName | The package name of the new package to make preferred. |
|---|
| permName | The name of the permission you are checking for, |
|---|---|
| pkgName | The name of the package you are checking against. |
| pkg1 | First package name whose signature will be compared. |
|---|---|
| pkg2 | Second package name whose signature will be compared. |
| activityName | Name of the activity whose icon is to be retrieved. |
|---|
| intent | The intent for which you would like to retrieve an icon. |
|---|
Throws PackageManager.NameNotFoundException if an activity with the given class name can not be found on the system.
| className | The full name (i.e. com.google.apps.contacts.ContactsList) of an Activity class. |
|---|---|
| flags | Additional option flags. Usually 0. |
| packageName | Name of the package whose application icon is to be retrieved. |
|---|
| info | Information about application being queried. |
|---|
Throws PackageManager.NameNotFoundException if an application with the given package name can not be found on the system.
| packageName | The full name (i.e. com.google.apps.contacts) of an application. |
|---|---|
| flags | Additional option flags. Currently should always be 0. |
| info | The application to get the label of |
|---|
| packageName | The name of the package that this icon is coming from. Can not be null. |
|---|---|
| resid | The resource identifier of the desired image. Can not be 0. |
| appInfo | Overall information about packageName. This may be null, in which case the application information will be retrieved for you if needed; if you already have this information around, it can be much more efficient to supply it here. |
| flags | Additional option flags. Currently should always be 0. |
|---|
| flags | Optional flags to control what information is returned. If 0, none of the optional information is returned. |
|---|
Throws PackageManager.NameNotFoundException if instrumentation with the given class name can not be found on the system.
| className | The full name (i.e. com.google.apps.contacts.InstrumentList) of an Instrumentation class. |
|---|---|
| flags | Additional option flags. Currently should always be 0. |
| uid | The user id for which you would like to retrieve a name. |
|---|
| archiveFilePath | The path to the archive file |
|---|---|
| flags | Optional flags to control what information is returned. If 0, none of the optional information is returned. |
Throws PackageManager.NameNotFoundException if apackage with the given name can not be found on the system.
| packageName | The full name (i.e. com.google.apps.contacts) of the desired package. |
|---|---|
| flags | Optional flags to control what information is returned. If 0, none of the optional information is returned. |
| uid | The user id for which you would like to retrieve the associated packages. |
|---|
Throws PackageManager.NameNotFoundException if an permission with the given name can not be found on the system.
| name | The fullly qualified name (i.e. com.google.permission.LOGIN) of the permission you are interested in. |
|---|---|
| flags | Additional option flags. Currently should always be 0. |
| flags | Optional flags to control what information is returned. If 0, none of the optional information is returned. |
|---|
Throws PackageManager.NameNotFoundException if a receiver with the given class name can not be found on the system.
| className | The full name (i.e. com.google.apps.contacts.CalendarAlarm) of a Receiver class. |
|---|---|
| flags | Additional option flags. Usually 0. |
| activityName | Name of the activity whose resources are to be retrieved. |
|---|
| app | Information about the desired application. |
|---|
| appPackageName | Package name of the application whose resources are to be retrieved. |
|---|
Throws PackageManager.NameNotFoundException if a service with the given class name can not be found on the system.
| className | The full name (i.e. com.google.apps.media.BackgroundPlayback) of a Service class. |
|---|---|
| flags | Additional option flags. Currently should always be 0. |
| packageName | The name of the package that this text is coming from. Can not be null. |
|---|---|
| resid | The resource identifier of the desired text. Can not be 0. |
| appInfo | Overall information about packageName. This may be null, in which case the application information will be retrieved for you if needed; if you already have this information around, it can be much more efficient to supply it here. |
| packageName | The name of the package that this xml is coming from. Can not be null. |
|---|---|
| resid | The resource identifier of the desired xml. Can not be 0. |
| appInfo | Overall information about packageName. This may be null, in which case the application information will be retrieved for you if needed; if you already have this information around, it can be much more efficient to supply it here. |
| packageURI | The location of the package file to install |
|---|
Note: unlike most other methods, an empty result set is indicated by a null return instead of an empty list.
| processName | If non-null, limits the returned providers to only those that are hosted by the given process. If null, all content providers are returned. |
|---|---|
| flags | Additional option flags. Currently should always be 0. |
| targetPackage | If null, all instrumentation is returned; only the instrumentation targeting this package name is returned. |
|---|---|
| flags | Additional option flags. Currently should always be 0. |
| intent | The desired intent as per resolveActivity(). |
|---|---|
| flags | Additional option flags. The most important is MATCH_DEFAULT_ONLY, to limit the resolution to only those activities that support the DEFAULT_CATEGORY. |