Developers can use Android Instant Apps in Google Play services for APIs providing compatibility to Activity and PackageManager methods. For example, the APIs allow you to get ApplicationInfo about an instant app, or to store a cookie on a device on SDK version lower than 26. If your instant app minSdkVersion is 26 or higher, you can use framework methods directly instead of using the compatibility library.
In addition to Google Play services libraries, the Android Instant Apps API provides methods to help you work within the instant apps context. To use this library, you must install the Instant Apps Development SDK from the SDK Manager. For more information about setting up the development environment, see Set up your development environment.
You also must include the following Gradle dependency in the build config file for any feature module that contains calls to this API:
compile 'com.google.android.instantapps:instantapps:1.1.0'
Package com.google.android.instantapps
Class Summary
| Class | Description |
|---|---|
| InstantApps | Android Instant Apps supporting API. |
Class InstantApps
| java.lang.Object | ||||
| ↳ |
com.google.android.instantapps.InstantApps
|
|||
The API supporting Android Instant Apps.
Summary
| Public methods | |
|---|---|
static boolean
|
This method returns true if the current process is an instant app. |
static boolean
|
Shows a dialog that allows the user to install the current instant app. |
|
|
Shows a dialog that allows the user to install the current instant app. Deprecated in Instant Apps SDK v1.1. Implement
|
Public methods
isInstantApp
boolean isInstantApp(
Context context)
This method returns true if the current process is an instant app.
| Parameters | |
|---|---|
context
|
Current activity or application context. |
| Returns | |
|---|---|
boolean
|
True if the current process is an instant app process. |
showInstallPrompt
public static boolean showInstallPrompt(
Activity activity,
Intent postInstallIntent,
int requestCode,
String referrer)
Shows a dialog that allows the user to install the current instant app. This method is a no-op if the current running process is an installed app. You must provide a post-install intent, which the system uses to start the application after install is complete.
| Parameters | |
|---|---|
activity
|
The activity launching the dialog. |
postInstallIntent
|
The intent to launch after the instant app has been installed. This intent *must* resolve to an activity in the installed app package, or it will not be used. |
requestCode
|
The request code to pass to Activity#startActivityForResult. |
referrer
|
The install referrer string. |
| Returns | |
|---|---|
boolean
|
True if the install prompt is successfully displayed. |
showInstallPrompt
boolean showInstallPrompt(
Activity activity,
int requestCode,
String referrer)
This method was deprecated in Instant Apps SDK v1.1.
Implement
showInstallPrompt(Activity, Intent, int, String) instead.
| Parameters | |
|---|---|
activity
|
The activity launching the dialog. |
requestCode
|
The requestCode to pass to
Activity.startActivityForResult().
|
referrer
|
The install referrer string that tracks conversions from instant app to installed app. |
| Returns | |
|---|---|
boolean
|
If the install prompt is successfully displayed |


