Skip to content

Most visited

Recently visited

navigation

Android Instant Apps API reference

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

isInstantApp(Context context)

This method returns true if the current process is an instant app.

static boolean

showInstallPrompt(Activity activity, Intent postInstallIntent, int requestCode, String referrer)

Shows a dialog that allows the user to install the current instant app.

static boolean

showInstallPrompt(Activity activity, int requestCode, String referrer)

Shows a dialog that allows the user to install the current instant app.

Deprecated in Instant Apps SDK v1.1. Implement showInstallPrompt(Activity, Intent, int, String) instead.

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
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)