public interface

PackageManagerCompat

com.google.android.gms.instantapps.PackageManagerCompat
Known Indirect Subclasses

Class Overview

A helper for accessing features in PackageManager in a backwards compatible fashion. Construct this by using getPackageManagerCompat(Context).

This helper exposes methods otherwise only available on some API levels. For other methods that exist on all API levels (e.g. getPackagesForUid(int) it will augment the results with data about instant apps as well as installed apps.

Summary

Public Methods
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 PackageInfo getPackageInfo(String packageName, int flags)
Retrieve overall information about an application package that is installed on the system or a running instant app.
abstract String[] getPackagesForUid(int uid)
Retrieve the names of all packages that are associated with a particular user id.
abstract boolean isInstantApp()
Returns true if this application is an instant app.
abstract boolean isInstantApp(String packageName)
Returns true if the provided package is that of a running instant app that has whitelisted the calling application.

Public Methods

public abstract ApplicationInfo getApplicationInfo (String packageName, int flags)

Retrieve all of the information we know about a particular package/application.

Information about installed apps will only be returned if requested when constructing the implementation of this interface; information about instant apps will only be returned if they are running and have whitelisted the calling application.

Parameters
packageName String: the full name (i.e. com.google.apps.contacts) of an application
flags int: additional option flags. Supported flags are defined in getApplicationInfo(String, int); instant apps will return data for the flag GET_META_DATA.
Returns
ApplicationInfo ApplicationInfo object containing information about the package.
Throws
PackageManager.NameNotFoundException if a package with the given name is not installed (or was not requested) and is not a package name of a running instant app

public abstract CharSequence getApplicationLabel (ApplicationInfo info)

Return the label to use for this application.

Information about installed apps will only be returned if requested when constructing the implementation of this interface; information about instant apps will only be returned if they are running and have whitelisted the calling application.

Parameters
info ApplicationInfo: The application to get the label of.
Returns
CharSequence Returns the label associated with this application, or null if it could not be found for any reason.

public abstract PackageInfo getPackageInfo (String packageName, int flags)

Retrieve overall information about an application package that is installed on the system or a running instant app.

Information about installed apps will only be returned if requested when constructing the implementation of this interface; information about instant apps will only be returned if they are running and have whitelisted the calling application.

Parameters
packageName String: the full name (i.e. com.google.apps.contacts) of the desired package
flags int: additional option flags. Supported flags are defined in getPackageInfo(String, int); instant apps will return data for the flags GET_ACTIVITIES, GET_CONFIGURATIONS, GET_META_DATA, GET_PERMISSIONS, and GET_SIGNATURES
Returns
PackageInfo PackageInfo object containing information about the package.
Throws
PackageManager.NameNotFoundException if a package with the given name is not installed (or was not requested) and is not a package name of a running instant app

public abstract String[] getPackagesForUid (int uid)

Retrieve the names of all packages that are associated with a particular user id.

Information about installed apps will only be returned if requested when constructing the implementation of this interface; information about instant apps will only be returned if they are running and have whitelisted the calling application.

Parameters
uid int: the user id for which you would like to retrieve the associated packages
Returns
String[] an array of one or more packages assigned to the user id, or null if there are no known packages with the given id

public abstract boolean isInstantApp ()

Returns true if this application is an instant app.

Returns
boolean true if this application is an instant app, false otherwise.

public abstract boolean isInstantApp (String packageName)

Returns true if the provided package is that of a running instant app that has whitelisted the calling application.

Parameters
packageName String: the package you want to check for being an instant app.
Returns
boolean true if the package is that of a running instant app, false otherwise.