CustomTabsService


abstract class CustomTabsService : Service


Abstract service class for implementing Custom Tabs related functionality. The service should be responding to the action ACTION_CUSTOM_TABS_CONNECTION. This class should be used by implementers that want to provide Custom Tabs functionality, not by clients that want to launch Custom Tabs.

Summary

Nested types

@Retention(value = RetentionPolicy.SOURCE)
@IntDef(value = )
annotation CustomTabsService.Relation
@Retention(value = RetentionPolicy.SOURCE)
@IntDef(value = )
annotation CustomTabsService.Result

Constants

const String!
ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService"

The Intent action that a CustomTabsService must respond to.

const String!
CATEGORY_COLOR_SCHEME_CUSTOMIZATION = "androidx.browser.customtabs.category.ColorSchemeCustomization"

An Intent filter category to signify that the Custom Tabs provider supports selecting and customizing color schemes via setColorScheme and setColorSchemeParams.

const String!
CATEGORY_NAVBAR_COLOR_CUSTOMIZATION = "androidx.browser.customtabs.category.NavBarColorCustomization"

An Intent filter category to signify that the Custom Tabs provider supports customizing the color of the navigation bar (setNavigationBarColor).

const String!
CATEGORY_TRUSTED_WEB_ACTIVITY_IMMERSIVE_MODE = "androidx.browser.trusted.category.ImmersiveMode"

An Intent filter category to signify that the Trusted Web Activity provider supports immersive mode.

const String!
CATEGORY_WEB_SHARE_TARGET_V2 = "androidx.browser.trusted.category.WebShareTargetV2"

An Intent filter category to signify that the Trusted Web Activity provider supports sending shared data according to the Web Share Target v2 protocol defined in https://wicg.github.io/web-share-target/level-2/.

const Int

A constant to be used with receiveFile indicating that the file is a splash image to be shown on top of a Trusted Web Activity while the web contents are loading.

const String!
KEY_SUCCESS = "androidx.browser.customtabs.SUCCESS"

The key to use to store a boolean in the returns bundle of extraCommand method, to indicate the command is executed successfully.

const String!
KEY_URL = "android.support.customtabs.otherurls.URL"

For mayLaunchUrl calls that wants to specify more than one url, this key can be used with putParcelable to insert a new url to each bundle inside list of bundles.

const Int

Used for validateRelationship.

const Int

Used for validateRelationship.

const Int

Indicates that the postMessage request was not allowed due to a bad argument or requesting at a disallowed time like when in background.

const Int

Indicates that the postMessage request has failed due to an internal error on the browser message channel.

const Int

Indicates that the postMessage request has failed due to a RemoteException .

const Int

Indicates that the postMessage request was accepted.

const String!
TRUSTED_WEB_ACTIVITY_CATEGORY = "androidx.browser.trusted.category.TrustedWebActivities"

An Intent filter category to signify that the Custom Tabs provider supports Trusted Web Activities (see TrustedWebUtils for more details).

Public constructors

Public functions

IBinder
onBind(intent: Intent?)

Protected functions

Boolean

Called when the client side IBinder for this CustomTabsSessionToken is dead.

abstract Bundle?
extraCommand(commandName: String, args: Bundle?)

Unsupported commands that may be provided by the implementation.

Boolean
isEngagementSignalsApiAvailable(
    sessionToken: CustomTabsSessionToken,
    extras: Bundle
)

Returns whether the Engagement Signals API is available.

abstract Boolean
mayLaunchUrl(
    sessionToken: CustomTabsSessionToken,
    url: Uri?,
    extras: Bundle?,
    otherLikelyBundles: (Mutable)List<Bundle!>?
)

Tells the browser of a likely future navigation to a URL.

abstract Boolean

Creates a new session through an ICustomTabsService with the optional callback.

abstract Int
@CustomTabsService.Result
postMessage(
    sessionToken: CustomTabsSessionToken,
    message: String,
    extras: Bundle?
)

Sends a postMessage request using the origin communicated via requestPostMessageChannel.

abstract Boolean
receiveFile(
    sessionToken: CustomTabsSessionToken,
    uri: Uri,
    purpose: Int,
    extras: Bundle?
)

Receive a file from client by given Uri, e.g. in order to display a large bitmap in a Custom Tab.

abstract Boolean
requestPostMessageChannel(
    sessionToken: CustomTabsSessionToken,
    postMessageOrigin: Uri
)

Sends a request to create a two way postMessage channel between the client and the browser linked with the given CustomTabsSession.

Boolean
requestPostMessageChannel(
    sessionToken: CustomTabsSessionToken,
    postMessageOrigin: Uri,
    postMessageTargetOrigin: Uri?,
    extras: Bundle
)

Same as above method with specifying the target origin to establish communication with.

Boolean
setEngagementSignalsCallback(
    sessionToken: CustomTabsSessionToken,
    callback: EngagementSignalsCallback,
    extras: Bundle
)

Sets an EngagementSignalsCallback to execute callbacks for events related to the user's engagement with the webpage within the tab.

abstract Boolean
updateVisuals(sessionToken: CustomTabsSessionToken, bundle: Bundle?)

Updates the visuals of custom tabs for the given session.

abstract Boolean
validateRelationship(
    sessionToken: CustomTabsSessionToken,
    @CustomTabsService.Relation relation: Int,
    origin: Uri,
    extras: Bundle?
)

Request to validate a relationship between the application and an origin.

abstract Boolean
warmup(flags: Long)

Warms up the browser process asynchronously.

Inherited Constants

From android.content.ComponentCallbacks2
From android.content.Context
const String!
ACCESSIBILITY_SERVICE = "accessibility"
const String!
ACCOUNT_SERVICE = "account"
const String!
ACTIVITY_SERVICE = "activity"
const String!
ALARM_SERVICE = "alarm"
const String!
APPWIDGET_SERVICE = "appwidget"
const String!
APP_OPS_SERVICE = "appops"
const String!
APP_SEARCH_SERVICE = "app_search"
const String!
AUDIO_SERVICE = "audio"
const String!
BATTERY_SERVICE = "batterymanager"
const Int
const Int
const Int
const Int
const Int
const Int
const Int
BIND_EXTERNAL_SERVICE = -2147483648
const Long
BIND_EXTERNAL_SERVICE_LONG = 4611686018427387904
const Int
const Int
const Int
const Int
const Int
const Int
const String!
BIOMETRIC_SERVICE = "biometric"
const String!
BLOB_STORE_SERVICE = "blob_store"
const String!
BLUETOOTH_SERVICE = "bluetooth"
const String!
BUGREPORT_SERVICE = "bugreport"
const String!
CAMERA_SERVICE = "camera"
const String!
CAPTIONING_SERVICE = "captioning"
const String!
CARRIER_CONFIG_SERVICE = "carrier_config"
const String!
CLIPBOARD_SERVICE = "clipboard"
const String!
COMPANION_DEVICE_SERVICE = "companiondevice"
const String!
CONNECTIVITY_DIAGNOSTICS_SERVICE = "connectivity_diagnostics"
const String!
CONNECTIVITY_SERVICE = "connectivity"
const String!
CONSUMER_IR_SERVICE = "consumer_ir"
const Int
const Int
const Int
const String!
CREDENTIAL_SERVICE = "credential"
const String!
CROSS_PROFILE_APPS_SERVICE = "crossprofileapps"
const Int
const Int
const String!
DEVICE_LOCK_SERVICE = "device_lock"
const String!
DEVICE_POLICY_SERVICE = "device_policy"
const String!
DISPLAY_HASH_SERVICE = "display_hash"
const String!
DISPLAY_SERVICE = "display"
const String!
DOMAIN_VERIFICATION_SERVICE = "domain_verification"
const String!
DOWNLOAD_SERVICE = "download"
const String!
DROPBOX_SERVICE = "dropbox"
const String!
EUICC_SERVICE = "euicc"
const String!
FILE_INTEGRITY_SERVICE = "file_integrity"
const String!
FINGERPRINT_SERVICE = "fingerprint"
const String!
GAME_SERVICE = "game"
const String!
GRAMMATICAL_INFLECTION_SERVICE = "grammatical_inflection"
const String!
HARDWARE_PROPERTIES_SERVICE = "hardware_properties"
const String!
HEALTHCONNECT_SERVICE = "healthconnect"
const String!
INPUT_METHOD_SERVICE = "input_method"
const String!
INPUT_SERVICE = "input"
const String!
IPSEC_SERVICE = "ipsec"
const String!
JOB_SCHEDULER_SERVICE = "jobscheduler"
const String!
KEYGUARD_SERVICE = "keyguard"
const String!
LAUNCHER_APPS_SERVICE = "launcherapps"
const String!
LAYOUT_INFLATER_SERVICE = "layout_inflater"
const String!
LOCALE_SERVICE = "locale"
const String!
LOCATION_SERVICE = "location"
const String!
MEDIA_COMMUNICATION_SERVICE = "media_communication"
const String!
MEDIA_METRICS_SERVICE = "media_metrics"
const String!
MEDIA_PROJECTION_SERVICE = "media_projection"
const String!
MEDIA_ROUTER_SERVICE = "media_router"
const String!
MEDIA_SESSION_SERVICE = "media_session"
const String!
MIDI_SERVICE = "midi"
const Int
MODE_APPEND = 32768
const Int
const Int

This property is deprecated.

const Int
const Int
const Int

This property is deprecated.

const Int

This property is deprecated.

const String!
const String!
NFC_SERVICE = "nfc"
const String!
NOTIFICATION_SERVICE = "notification"
const String!
NSD_SERVICE = "servicediscovery"
const String!
OVERLAY_SERVICE = "overlay"
const String!
PEOPLE_SERVICE = "people"
const String!
PERFORMANCE_HINT_SERVICE = "performance_hint"
const String!
POWER_SERVICE = "power"
const String!
PRINT_SERVICE = "print"
const Int
const Int
const Int
const String!
RESTRICTIONS_SERVICE = "restrictions"
const String!
ROLE_SERVICE = "role"
const String!
SEARCH_SERVICE = "search"
const String!
SENSOR_SERVICE = "sensor"
const String!
SHORTCUT_SERVICE = "shortcut"
const String!
STATUS_BAR_SERVICE = "statusbar"
const String!
STORAGE_SERVICE = "storage"
const String!
STORAGE_STATS_SERVICE = "storagestats"
const String!
SYSTEM_HEALTH_SERVICE = "systemhealth"
const String!
TELECOM_SERVICE = "telecom"
const String!
TELEPHONY_IMS_SERVICE = "telephony_ims"
const String!
const String!
TELEPHONY_SUBSCRIPTION_SERVICE = "telephony_subscription_service"
const String!
TEXT_CLASSIFICATION_SERVICE = "textclassification"
const String!
const String!
TV_INPUT_SERVICE = "tv_input"
const String!
TV_INTERACTIVE_APP_SERVICE = "tv_interactive_app"
const String!
UI_MODE_SERVICE = "uimode"
const String!
USAGE_STATS_SERVICE = "usagestats"
const String!
USB_SERVICE = "usb"
const String!
USER_SERVICE = "user"
const String!
VIBRATOR_MANAGER_SERVICE = "vibrator_manager"
const String!
VIBRATOR_SERVICE = "vibrator"

This property is deprecated.

const String!
VIRTUAL_DEVICE_SERVICE = "virtualdevice"
const String!
VPN_MANAGEMENT_SERVICE = "vpn_management"
const String!
WALLPAPER_SERVICE = "wallpaper"
const String!
WIFI_AWARE_SERVICE = "wifiaware"
const String!
WIFI_P2P_SERVICE = "wifip2p"
const String!
const String!
WIFI_SERVICE = "wifi"
const String!
WINDOW_SERVICE = "window"
From android.app.Service

Inherited functions

From android.content.Context
From android.content.ContextWrapper
Boolean
bindIsolatedService(
    service: Intent!,
    flags: Int,
    instanceName: String!,
    executor: Executor!,
    conn: ServiceConnection!
)
Boolean
bindService(service: Intent!, conn: ServiceConnection!, flags: Int)
Boolean
bindServiceAsUser(
    service: Intent!,
    conn: ServiceConnection!,
    flags: Int,
    user: UserHandle!
)
Int
Int
IntArray<Int>!
checkCallingOrSelfUriPermissions(
    uris: (Mutable)List<Uri!>!,
    modeFlags: Int
)
Int
Int
checkCallingUriPermission(uri: Uri!, modeFlags: Int)
IntArray<Int>!
checkCallingUriPermissions(uris: (Mutable)List<Uri!>!, modeFlags: Int)
Int
checkPermission(permission: String!, pid: Int, uid: Int)
Int
Int
checkUriPermission(uri: Uri!, pid: Int, uid: Int, modeFlags: Int)
IntArray<Int>!
checkUriPermissions(
    uris: (Mutable)List<Uri!>!,
    pid: Int,
    uid: Int,
    modeFlags: Int
)
Unit

This function is deprecated.

Context!
createAttributionContext(attributionTag: String!)
Context!
createConfigurationContext(overrideConfiguration: Configuration!)
Context!
createContext(contextParams: ContextParams!)
Context!
Context!
Context!
Context!
Context!
createPackageContext(packageName: String!, flags: Int)
Context!
createWindowContext(type: Int, options: Bundle!)
Array<String!>!
Boolean
Boolean
Boolean
Unit
enforceCallingOrSelfPermission(permission: String!, message: String!)
Unit
enforceCallingOrSelfUriPermission(
    uri: Uri!,
    modeFlags: Int,
    message: String!
)
Unit
enforceCallingPermission(permission: String!, message: String!)
Unit
enforceCallingUriPermission(uri: Uri!, modeFlags: Int, message: String!)
Unit
enforcePermission(permission: String!, pid: Int, uid: Int, message: String!)
Unit
enforceUriPermission(
    uri: Uri!,
    pid: Int,
    uid: Int,
    modeFlags: Int,
    message: String!
)
Array<String!>!
Context!
ApplicationInfo!
AssetManager!
AttributionSource!
String!
Context!
File!
ClassLoader!
File!
ContentResolver!
File!
File!
Int
File!
getDir(name: String!, mode: Int)
Display!
File!
Array<File!>!
File!
Array<File!>!
Array<File!>!

This function is deprecated.

File!
File!
Executor!
Looper!
File!
File!
Array<File!>!
String!
String!
PackageManager!
String!
String!
ContextParams!
Resources!
SharedPreferences!
getSharedPreferences(name: String!, mode: Int)
Any!
String!
getSystemServiceName(serviceClass: Class<Any!>!)
Resources.Theme!
Drawable!

This function is deprecated.

Int

This function is deprecated.

Int

This function is deprecated.

Unit
grantUriPermission(toPackage: String!, uri: Uri!, modeFlags: Int)
Boolean
Boolean
Boolean
Boolean
moveDatabaseFrom(sourceContext: Context!, name: String!)
Boolean
moveSharedPreferencesFrom(sourceContext: Context!, name: String!)
FileInputStream!
FileOutputStream!
openFileOutput(name: String!, mode: Int)
SQLiteDatabase!
openOrCreateDatabase(
    name: String!,
    mode: Int,
    factory: SQLiteDatabase.CursorFactory!
)
Drawable!

This function is deprecated.

Unit
Unit
Intent!
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
Unit
revokeUriPermission(uri: Uri!, modeFlags: Int)
Unit
Unit
Unit
sendOrderedBroadcast(intent: Intent!, receiverPermission: String!)
Unit
sendOrderedBroadcastAsUser(
    intent: Intent!,
    user: UserHandle!,
    receiverPermission: String!,
    resultReceiver: BroadcastReceiver!,
    scheduler: Handler!,
    initialCode: Int,
    initialData: String!,
    initialExtras: Bundle!
)
Unit

This function is deprecated.

Unit

This function is deprecated.

Unit
sendStickyOrderedBroadcast(
    intent: Intent!,
    resultReceiver: BroadcastReceiver!,
    scheduler: Handler!,
    initialCode: Int,
    initialData: String!,
    initialExtras: Bundle!
)

This function is deprecated.

Unit
sendStickyOrderedBroadcastAsUser(
    intent: Intent!,
    user: UserHandle!,
    resultReceiver: BroadcastReceiver!,
    scheduler: Handler!,
    initialCode: Int,
    initialData: String!,
    initialExtras: Bundle!
)

This function is deprecated.

Unit
setTheme(resid: Int)
Unit
setWallpaper(bitmap: Bitmap!)

This function is deprecated.

Unit
Unit
ComponentName!
Boolean
startInstrumentation(
    className: ComponentName!,
    profileFile: String!,
    arguments: Bundle!
)
Unit
startIntentSender(
    intent: IntentSender!,
    fillInIntent: Intent!,
    flagsMask: Int,
    flagsValues: Int,
    extraFlags: Int
)
ComponentName!
startService(service: Intent!)
Boolean
Unit
Unit
Unit
Unit
Unit
updateServiceGroup(conn: ServiceConnection!, group: Int, importance: Int)
From android.app.Service
Unit
Unit
dump(fd: FileDescriptor!, writer: PrintWriter!, args: Array<String!>!)
Application!
Int
Unit
Unit
Unit
Unit
Unit
onRebind(intent: Intent!)
Unit
onStart(intent: Intent!, startId: Int)

This function is deprecated.

Int
onStartCommand(intent: Intent!, flags: Int, startId: Int)
Unit
onTaskRemoved(rootIntent: Intent!)
Unit
onTimeout(startId: Int)
Unit
onTrimMemory(level: Int)
Boolean
onUnbind(intent: Intent!)
Unit
startForeground(id: Int, notification: Notification!)
Unit
stopForeground(removeNotification: Boolean)

This function is deprecated.

Unit
Boolean
stopSelfResult(startId: Int)

Constants

ACTION_CUSTOM_TABS_CONNECTION

Added in 1.2.0
const val ACTION_CUSTOM_TABS_CONNECTION = "android.support.customtabs.action.CustomTabsService": String!

The Intent action that a CustomTabsService must respond to.

CATEGORY_COLOR_SCHEME_CUSTOMIZATION

Added in 1.2.0
const val CATEGORY_COLOR_SCHEME_CUSTOMIZATION = "androidx.browser.customtabs.category.ColorSchemeCustomization": String!

An Intent filter category to signify that the Custom Tabs provider supports selecting and customizing color schemes via setColorScheme and setColorSchemeParams.

CATEGORY_NAVBAR_COLOR_CUSTOMIZATION

Added in 1.2.0
const val CATEGORY_NAVBAR_COLOR_CUSTOMIZATION = "androidx.browser.customtabs.category.NavBarColorCustomization": String!

An Intent filter category to signify that the Custom Tabs provider supports customizing the color of the navigation bar (setNavigationBarColor).

CATEGORY_TRUSTED_WEB_ACTIVITY_IMMERSIVE_MODE

Added in 1.2.0
const val CATEGORY_TRUSTED_WEB_ACTIVITY_IMMERSIVE_MODE = "androidx.browser.trusted.category.ImmersiveMode": String!

An Intent filter category to signify that the Trusted Web Activity provider supports immersive mode.

CATEGORY_WEB_SHARE_TARGET_V2

Added in 1.2.0
const val CATEGORY_WEB_SHARE_TARGET_V2 = "androidx.browser.trusted.category.WebShareTargetV2": String!

An Intent filter category to signify that the Trusted Web Activity provider supports sending shared data according to the Web Share Target v2 protocol defined in https://wicg.github.io/web-share-target/level-2/.

FILE_PURPOSE_TRUSTED_WEB_ACTIVITY_SPLASH_IMAGE

Added in 1.2.0
const val FILE_PURPOSE_TRUSTED_WEB_ACTIVITY_SPLASH_IMAGE = 1: Int

A constant to be used with receiveFile indicating that the file is a splash image to be shown on top of a Trusted Web Activity while the web contents are loading.

KEY_SUCCESS

Added in 1.3.0
const val KEY_SUCCESS = "androidx.browser.customtabs.SUCCESS": String!

The key to use to store a boolean in the returns bundle of extraCommand method, to indicate the command is executed successfully.

KEY_URL

Added in 1.2.0
const val KEY_URL = "android.support.customtabs.otherurls.URL": String!

For mayLaunchUrl calls that wants to specify more than one url, this key can be used with putParcelable to insert a new url to each bundle inside list of bundles.

RELATION_HANDLE_ALL_URLS

Added in 1.2.0
const val RELATION_HANDLE_ALL_URLS = 2: Int

Used for validateRelationship. Requests the ability to handle all URLs from a given origin.

RELATION_USE_AS_ORIGIN

Added in 1.2.0
const val RELATION_USE_AS_ORIGIN = 1: Int

Used for validateRelationship. For App -> Web transitions, requests the app to use the declared origin to be used as origin for the client app in the web APIs context.

RESULT_FAILURE_DISALLOWED

Added in 1.2.0
const val RESULT_FAILURE_DISALLOWED = -1: Int

Indicates that the postMessage request was not allowed due to a bad argument or requesting at a disallowed time like when in background.

RESULT_FAILURE_MESSAGING_ERROR

Added in 1.2.0
const val RESULT_FAILURE_MESSAGING_ERROR = -3: Int

Indicates that the postMessage request has failed due to an internal error on the browser message channel.

RESULT_FAILURE_REMOTE_ERROR

Added in 1.2.0
const val RESULT_FAILURE_REMOTE_ERROR = -2: Int

Indicates that the postMessage request has failed due to a RemoteException .

RESULT_SUCCESS

Added in 1.2.0
const val RESULT_SUCCESS = 0: Int

Indicates that the postMessage request was accepted.

TRUSTED_WEB_ACTIVITY_CATEGORY

Added in 1.2.0
const val TRUSTED_WEB_ACTIVITY_CATEGORY = "androidx.browser.trusted.category.TrustedWebActivities": String!

An Intent filter category to signify that the Custom Tabs provider supports Trusted Web Activities (see TrustedWebUtils for more details).

Public constructors

CustomTabsService

Added in 1.2.0
CustomTabsService()

Public functions

onBind

Added in 1.2.0
fun onBind(intent: Intent?): IBinder

Protected functions

cleanUpSession

Added in 1.2.0
protected fun cleanUpSession(sessionToken: CustomTabsSessionToken): Boolean

Called when the client side IBinder for this CustomTabsSessionToken is dead. Can also be used to clean up DeathRecipient instances allocated for the given token.

Parameters
sessionToken: CustomTabsSessionToken

The session token for which the DeathRecipient call has been received.

Returns
Boolean

Whether the clean up was successful. Multiple calls with two tokens holdings the same binder will return false.

extraCommand

Added in 1.2.0
protected abstract fun extraCommand(commandName: String, args: Bundle?): Bundle?

Unsupported commands that may be provided by the implementation.

Note:Clients should never rely on this method to have a defined behavior, as it is entirely implementation-defined and not supported.

This call can be used by implementations to add extra commands, for testing or experimental purposes. A return value of null will be used to signify that the client does not know how to handle the request. As optional best practices, KEY_SUCCESS could be use to identify that command was *successfully* handled. For example, when returning a message with result:

    Bundle result = new Bundle();
    result.putString("message", message);
    if (success)
        result.putBoolean(KEY_SUCCESS, true);
    return result;
The caller side:
    Bundle result = service.extraCommand(commandName, args);
    if (result.getBoolean(service.KEY_SUCCESS)) {
        // Command was successfully handled
    }
Parameters
commandName: String

Name of the extra command to execute.

args: Bundle?

Arguments for the command

Returns
Bundle?

The result Bundle, or null.

isEngagementSignalsApiAvailable

Added in 1.6.0
protected fun isEngagementSignalsApiAvailable(
    sessionToken: CustomTabsSessionToken,
    extras: Bundle
): Boolean

Returns whether the Engagement Signals API is available. The availability of the Engagement Signals API may change at runtime. If an EngagementSignalsCallback has been set, an onSessionEnded signal will be sent if the API becomes unavailable later.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session.

extras: Bundle

Reserved for future use.

Returns
Boolean

Whether the Engagement Signals API is available. A false value means setEngagementSignalsCallback will return false and not set the callback.

mayLaunchUrl

Added in 1.2.0
protected abstract fun mayLaunchUrl(
    sessionToken: CustomTabsSessionToken,
    url: Uri?,
    extras: Bundle?,
    otherLikelyBundles: (Mutable)List<Bundle!>?
): Boolean

Tells the browser of a likely future navigation to a URL.

The method warmup has to be called beforehand. The most likely URL has to be specified explicitly. Optionally, a list of other likely URLs can be provided. They are treated as less likely than the first one, and have to be sorted in decreasing priority order. These additional URLs may be ignored. All previous calls to this method will be deprioritized.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session. Can not be null.

url: Uri?

Most likely URL.

extras: Bundle?

Reserved for future use.

otherLikelyBundles: (Mutable)List<Bundle!>?

Other likely destinations, sorted in decreasing likelihood order. Each Bundle has to provide a url.

Returns
Boolean

Whether the call was successful.

newSession

Added in 1.2.0
protected abstract fun newSession(sessionToken: CustomTabsSessionToken): Boolean

Creates a new session through an ICustomTabsService with the optional callback. This session can be used to associate any related communication through the service with an intent and then later with a Custom Tab. The client can then send later service calls or intents to through same session-intent-Custom Tab association.

Parameters
sessionToken: CustomTabsSessionToken

Session token to be used as a unique identifier. This also has access to the CustomTabsCallback passed from the client side through getCallback.

Returns
Boolean

Whether a new session was successfully created.

postMessage

Added in 1.2.0
@CustomTabsService.Result
protected abstract fun postMessage(
    sessionToken: CustomTabsSessionToken,
    message: String,
    extras: Bundle?
): Int

Sends a postMessage request using the origin communicated via requestPostMessageChannel. Fails when called before notifyMessageChannelReady is received on the client side.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session. Can not be null.

message: String

The message that is being sent.

extras: Bundle?

Reserved for future use.

Returns
Int

An integer constant about the postMessage request result. Will return RESULT_SUCCESS if successful.

receiveFile

Added in 1.2.0
protected abstract fun receiveFile(
    sessionToken: CustomTabsSessionToken,
    uri: Uri,
    purpose: Int,
    extras: Bundle?
): Boolean

Receive a file from client by given Uri, e.g. in order to display a large bitmap in a Custom Tab. Prior to calling this method, the client grants a read permission to the target Custom Tabs provider via grantUriPermission. The file is read and processed (where applicable) synchronously.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session.

uri: Uri

Uri of the file.

purpose: Int

Purpose of transferring this file, one of the constants enumerated in CustomTabsService#FilePurpose.

extras: Bundle?

Reserved for future use.

Returns
Boolean

true if the file was received successfully.

requestPostMessageChannel

Added in 1.2.0
protected abstract fun requestPostMessageChannel(
    sessionToken: CustomTabsSessionToken,
    postMessageOrigin: Uri
): Boolean

Sends a request to create a two way postMessage channel between the client and the browser linked with the given CustomTabsSession.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session. Can not be null.

postMessageOrigin: Uri

A origin that the client is requesting to be identified as during the postMessage communication.

Returns
Boolean

Whether the implementation accepted the request. Note that returning true here doesn't mean an origin has already been assigned as the validation is asynchronous.

requestPostMessageChannel

Added in 1.6.0
protected fun requestPostMessageChannel(
    sessionToken: CustomTabsSessionToken,
    postMessageOrigin: Uri,
    postMessageTargetOrigin: Uri?,
    extras: Bundle
): Boolean

Same as above method with specifying the target origin to establish communication with.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session. Can not be null.

postMessageOrigin: Uri

A origin that the client is requesting to be identified as during the postMessage communication.

postMessageTargetOrigin: Uri?

The target Origin to establish PostMessageChannel with and send messages to.

extras: Bundle

Reserved for future use.

Returns
Boolean

Whether the implementation accepted the request. Note that returning true here doesn't mean an origin has already been assigned as the validation is asynchronous.

setEngagementSignalsCallback

Added in 1.6.0
protected fun setEngagementSignalsCallback(
    sessionToken: CustomTabsSessionToken,
    callback: EngagementSignalsCallback,
    extras: Bundle
): Boolean

Sets an EngagementSignalsCallback to execute callbacks for events related to the user's engagement with the webpage within the tab.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session.

callback: EngagementSignalsCallback

The EngagementSignalsCallback to execute the callbacks.

extras: Bundle

Reserved for future use.

Returns
Boolean

Whether the callback connection is allowed. If false, no callbacks will be called for this session.

updateVisuals

Added in 1.2.0
protected abstract fun updateVisuals(sessionToken: CustomTabsSessionToken, bundle: Bundle?): Boolean

Updates the visuals of custom tabs for the given session. Will only succeed if the given session matches the currently active one.

Parameters
sessionToken: CustomTabsSessionToken

The currently active session that the custom tab belongs to.

bundle: Bundle?

The action button configuration bundle. This bundle should be constructed with the same structure in CustomTabsIntent.Builder.

Returns
Boolean

Whether the operation was successful.

validateRelationship

Added in 1.2.0
protected abstract fun validateRelationship(
    sessionToken: CustomTabsSessionToken,
    @CustomTabsService.Relation relation: Int,
    origin: Uri,
    extras: Bundle?
): Boolean

Request to validate a relationship between the application and an origin. If this method returns true, the validation result will be provided through onRelationshipValidationResult. Otherwise the request didn't succeed. The client must call warmup before this.

Parameters
sessionToken: CustomTabsSessionToken

The unique identifier for the session. Can not be null.

@CustomTabsService.Relation relation: Int

Relation to check, must be one of the CustomTabsService#RELATION_* constants.

origin: Uri

Origin for the relation query.

extras: Bundle?

Reserved for future use.

Returns
Boolean

true if the request has been submitted successfully.

warmup

Added in 1.2.0
protected abstract fun warmup(flags: Long): Boolean

Warms up the browser process asynchronously.

Parameters
flags: Long

Reserved for future use.

Returns
Boolean

Whether warmup was/had been completed successfully. Multiple successful calls will return true.