com.google.android.gms.instantapps.PackageManagerCompat |
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.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Retrieve all of the information we know about a particular package/application.
| |||||||||||
Return the label to use for this application.
| |||||||||||
Retrieve the package name of the application that installed a package.
| |||||||||||
Gets the instant application cookie for this app.
| |||||||||||
Gets the maximum size in bytes of the cookie data an instant app can store on the device.
| |||||||||||
Retrieve overall information about an application package that is installed on the system or a
running instant app.
| |||||||||||
Retrieve the names of all packages that are associated with a particular user id.
| |||||||||||
Returns true if this application is an instant app.
| |||||||||||
Returns true if the provided package is that of a running instant app that has whitelisted the
calling application.
| |||||||||||
Sets the instant application cookie for the calling app.
|
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 |
See also:
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. |
See also:
Retrieve the package name of the application that installed a package. This identifies which market the package came from.
Parameters | |
---|---|
packageName |
String : The name of the package to query
|
Returns | |
---|---|
String |
Gets the instant application cookie for this app. Non instant apps and apps that were instant but were upgraded to normal apps can still access this API. For instant apps this cookie is cached for some time after uninstall while for normal apps the cookie is deleted after the app is uninstalled. The cookie is always present while the app is installed.
This can be called by instant apps or installed apps.
Returns | |
---|---|
byte[] |
The cookie, or null if no cookie was previously-set. |
Gets the maximum size in bytes of the cookie data an instant app can store on the device.
This can be called by instant apps or installed apps.
Returns | |
---|---|
int |
The max cookie size in bytes. |
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 |
See also:
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 |
See also:
Returns true if this application is an instant app.
Returns | |
---|---|
boolean |
true if this application is an instant app, false otherwise. |
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. |
Sets the instant application cookie for the calling app. Non instant apps and apps that were
instant but were upgraded to normal apps can still access this API. For instant apps this
cookie is cached for some time after uninstall while for normal apps the cookie is deleted
after the app is uninstalled. The cookie is always present while the app is installed. The
cookie size is limited by getInstantAppCookieMaxSize()
. If the provided cookie size is
over the limit this method returns false
. Passing null
or an empty
array clears the cookie.
Parameters | |
---|---|
cookie |
byte : The cookie data. |
Returns | |
---|---|
boolean |
True if the cookie was set. False if cookie is too large or I/O fails. |