com.google.android.gms.instantapps.Launcher |
API for launching instant apps. For example, browsers can use this API to check if given URL has an associated instant app and obtain an intent that can be used to launch it.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | EXTRA_DO_NOT_LAUNCH_INSTANT_APP | Boolean extra with true value added to the fallback intent passed to getInstantAppIntentData(String, Intent) . |
|||||||||
String | EXTRA_IS_REFERRER_TRUSTED | Boolean extra that can be attached to the intent you obtained from getInstantAppIntentData(String, Intent) or getInstantAppLaunchData(String) . |
|||||||||
String | EXTRA_IS_USER_CONFIRMED_LAUNCH | Boolean extra that can be attached to the intent you obtained from getInstantAppIntentData(String, Intent) or getInstantAppLaunchData(String) . |
|||||||||
String | EXTRA_TRUSTED_REFERRER_PKG | String extra that can be attached to the intent you obtained from getInstantAppIntentData(String, Intent) or getInstantAppLaunchData(String) . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Checks if the given URL can be launched as an instant app on this device.
| |||||||||||
Returns
LaunchData that can be used to start an instant app. | |||||||||||
Initializes the client for getting intents for launching instant apps.
|
Boolean extra with true value added to the fallback intent passed to getInstantAppIntentData(String, Intent)
. It indicates to the fallback intent handler that the
intent was started after a failure to load an instant app so that the handler will not attempt
to launch an instant app while handling this fallback intent.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
See also:
Boolean extra that can be attached to the intent you obtained from getInstantAppIntentData(String, Intent)
or getInstantAppLaunchData(String)
.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
When the instant app URL click happens within your app, the you can attach an extra EXTRA_REFERRER
with the URI to which the click should be attributed, respecting
referrer policy. For example, a web browser can attach the URI of the web page on which this
link was clicked.
If you are certain what the referrer is you should set this extra to true. When the referrer is sent by an external party and it cannot be verified, then you should set this to false.
See also:
Boolean extra that can be attached to the intent you obtained from getInstantAppIntentData(String, Intent)
or getInstantAppLaunchData(String)
.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
The value indicates whether you have obtained user confirmation for this instant app launch. Confirmation should be explicit and for this specific launch. This may be used to determine whether user confirmation should be obtained by the instant app launcher. For example, if you have a 'Launch instant app' button that launches the intent then it would be appropriate to set this extra to true so that user is not redundantly asked if they want to launch instant app by the instant apps runtime. This is a suggestion and may not always result in suppression of additional user confirmation.
See also:
String extra that can be attached to the intent you obtained from getInstantAppIntentData(String, Intent)
or getInstantAppLaunchData(String)
.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
String extra containing the package name of the Android app where the instant app URL click happened. For example, it would contain the package name of your browser application which is launching instant app.
You should set this if conditions for EXTRA_IS_REFERRER_TRUSTED
are met.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
Checks if the given URL can be launched as an instant app on this device. Returned data object
describes whether the link should launch an instant app, and if so provides an activity Intent
to launch an instant app via startActivity(Intent)
.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
After calling this method check getMatchResult()
to see if the
intent obtained from getIntent()
should be used to launch an instant
app. Before launching, the following extras can be attached as appropriate: EXTRA_REFERRER
,EXTRA_TRUSTED_REFERRER_PKG
, EXTRA_IS_REFERRER_TRUSTED
,
EXTRA_IS_USER_CONFIRMED_LAUNCH
, EXTRA_APPLICATION_ID
,
android.nfc.NfcAdapter#EXTRA_NDEF_MESSAGES
, android.nfc.NfcAdapter#EXTRA_TAG
,
and android.nfc.NfcAdapter#EXTRA_ID
.
Even after the intent is launched the instant app is not guaranteed to be launched due to
changing conditions on device. In this case the runtime will launch the provided fallbackIntent
. EXTRA_DO_NOT_LAUNCH_INSTANT_APP
with a true
value will be
added to the fallbackIntent
to indicate to the Activity handling it that it should not
attempt to launch an instant app while handling this fallbackIntent
. For example, if
fallbackIntent
is a URL intent that points back to the same browser that attempted to
launch instant app then the browser should check this extra and avoid launching instant app
again to prevent an infinite redirect loop.
This is a fast on-device API. initializeIntentClient()
can be used to
pre-initialize the client to further speed up lookup.
Parameters | |
---|---|
url |
String : URL for which an instant app is needed |
fallbackIntent |
Intent : Activity Intent that will be run by the handler of the returned instant
app Intent when it cannot launch an instant app. The fallbackIntent 's URI must
match url . The Activity targeted by fallbackIntent must have CATEGORY_BROWSABLE in its intent filter. If fallbackIntent is null or these
conditions are not met then, when necessary, an implicit Intent with the same URL will be
sent instead of fallbackIntent . |
Returns | |
---|---|
InstantAppIntentData |
launch data that can potentially start an instant app, or indicate that instant app cannot be launched because it is unavailable for given URL or user prefers viewing URL in browser. |
Returns LaunchData
that can be used to start an instant app.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
This method provides extra information such as app icon and title in addition to a lookup
performed by getInstantAppIntentData(String, Intent)
. It may involve server requests
and may be slower.
If an instant app can be launched for the given URL then getIntent()
will
return an intent that can be used to start the instant app. Otherwise, it will return null.
Extras can be attached to the intent similarly to those described in getInstantAppIntentData(String, Intent)
.
When an intent is returned it is not guaranteed that an instant app can be launched. In such cases, when the returned intent is started there will be no callback to the caller to indicate failure to launch an instant app. Implicit intent to view the URL will be launched instead.
This method may involve RPCs to the server and may be slower than getInstantAppIntentData(String, Intent)
.
Parameters | |
---|---|
url |
String : the URL for which an instant app is needed. |
Returns | |
---|---|
Task<LaunchData> |
LaunchData
|
See also:
Initializes the client for getting intents for launching instant apps. This can optionally be
done prior to invoking getInstantAppIntentData(String, Intent)
in order to perform
initialization ahead of time.
Returns true if initialization succeeded, false if it failed (in which case all future
invocations of getInstantAppIntentData(String, Intent)
will return null.
Meant for use by apps that want to launch instant apps, e.g. web browsers.
Returns | |
---|---|
boolean |
See also: