belongs to Maven artifact com.android.support:customtabs:28.0.0-alpha1
CustomTabsSession
  public
  
  final
  
  class
  CustomTabsSession
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.support.customtabs.CustomTabsSession | 
A class to be used for Custom Tabs related communication. Clients that want to launch Custom Tabs can use this class exclusively to handle all related communication.
Summary
| Public methods | |
|---|---|
| 
        
        
        static
        
        
        CustomTabsSession | 
      createMockSessionForTesting(ComponentName componentName)
      Provides browsers a way to generate a mock  | 
| 
        
        
        
        
        
        boolean | 
      mayLaunchUrl(Uri url, Bundle extras, List<Bundle> otherLikelyBundles)
      Tells the browser of a likely future navigation to a URL. | 
| 
        
        
        
        
        
        int | 
      postMessage(String message, Bundle extras)
      Sends a postMessage request using the origin communicated via
  | 
| 
        
        
        
        
        
        boolean | 
      requestPostMessageChannel(Uri postMessageOrigin)
      Sends a request to create a two way postMessage channel between the client and the browser. | 
| 
        
        
        
        
        
        boolean | 
      setActionButton(Bitmap icon, String description)
      This sets the action button on the toolbar with ID
  | 
| 
        
        
        
        
        
        boolean | 
      setSecondaryToolbarViews(RemoteViews remoteViews, int[] clickableIDs, PendingIntent pendingIntent)
      Updates the  | 
| 
        
        
        
        
        
        boolean | 
      setToolbarItem(int id, Bitmap icon, String description)
      This method was deprecated in API level 25.1.0. Use CustomTabsSession#setSecondaryToolbarViews(RemoteViews, int[], PendingIntent) | 
| 
        
        
        
        
        
        boolean | 
      validateRelationship(int relation, Uri origin, Bundle extras)
      Requests to validate a relationship between the application and an origin. | 
| Inherited methods | |
|---|---|
|  From
class 
  
    java.lang.Object
  
 | |
Public methods
createMockSessionForTesting
CustomTabsSession createMockSessionForTesting (ComponentName componentName)
Provides browsers a way to generate a mock CustomTabsSession for testing
 purposes.
| Parameters | |
|---|---|
| componentName | ComponentName: The component the session should be created for. | 
| Returns | |
|---|---|
| CustomTabsSession | A mock session with no functionality. | 
mayLaunchUrl
boolean mayLaunchUrl (Uri url, Bundle extras, List<Bundle> otherLikelyBundles)
Tells the browser of a likely future navigation to a URL. The most likely URL has to be specified first. 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 | |
|---|---|
| url | Uri: Most likely URL. | 
| extras | Bundle: Reserved for future use. | 
| otherLikelyBundles | List: Other likely destinations, sorted in decreasing
                           likelihood order. Inside each Bundle, the client should provide aUriusingKEY_URLwithputParcelable(String, android.os.Parcelable). | 
| Returns | |
|---|---|
| boolean | true for success. | 
postMessage
int postMessage (String message, 
                Bundle extras)Sends a postMessage request using the origin communicated via
 requestPostMessageChannel(CustomTabsSessionToken, Uri). Fails when called before
 notifyMessageChannelReady(Bundle) is received on
 the client side.
| Parameters | |
|---|---|
| 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_SUCCESSif successful. | 
requestPostMessageChannel
boolean requestPostMessageChannel (Uri postMessageOrigin)
Sends a request to create a two way postMessage channel between the client and the browser.
| Parameters | |
|---|---|
| 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. | 
setActionButton
boolean setActionButton (Bitmap icon, String description)
This sets the action button on the toolbar with ID
 TOOLBAR_ACTION_BUTTON_ID.
| Parameters | |
|---|---|
| icon | Bitmap: The new icon of the action button. | 
| description | String: Content description of the action button. | 
| Returns | |
|---|---|
| boolean | |
See also:
setSecondaryToolbarViews
boolean setSecondaryToolbarViews (RemoteViews remoteViews, int[] clickableIDs, PendingIntent pendingIntent)
Updates the RemoteViews of the secondary toolbar in an existing custom tab session.
| Parameters | |
|---|---|
| remoteViews | RemoteViews: The updatedRemoteViewsthat will be shown in secondary toolbar.
                      If null, the current secondary toolbar will be dismissed. | 
| clickableIDs | int: The ids of clickable views. The onClick event of these views will be
                      handled by custom tabs. | 
| pendingIntent | PendingIntent: ThePendingIntentthat will be sent when the user clicks on one
                      of theViews in clickableIDs. | 
| Returns | |
|---|---|
| boolean | |
setToolbarItem
boolean setToolbarItem (int id, 
                Bitmap icon, 
                String description)
      This method was deprecated
      in API level 25.1.0.
    Use
 CustomTabsSession#setSecondaryToolbarViews(RemoteViews, int[], PendingIntent)
  
Updates the visuals for toolbar items. Will only succeed if a custom tab created using this session is in the foreground in browser and the given id is valid.
| Parameters | |
|---|---|
| id | int: The id for the item to update. | 
| icon | Bitmap: The new icon of the toolbar item. | 
| description | String: Content description of the toolbar item. | 
| Returns | |
|---|---|
| boolean | Whether the update succeeded. | 
validateRelationship
boolean validateRelationship (int relation, 
                Uri origin, 
                Bundle extras)Requests to validate a relationship between the application and an origin.
See here for documentation about Digital Asset Links. This methods requests the browser to verify a relation with the calling application, to grant the associated rights.
 If this method returns true, the validation result will be provided through
 onRelationshipValidationResult(int, Uri, boolean, Bundle).
 Otherwise the request didn't succeed. The client must call
 warmup(long) before this.
| Parameters | |
|---|---|
| relation | int: Relation to check, must be one of theCustomTabsService#RELATION_* constants. | 
| origin | Uri: Origin. | 
| extras | Bundle: Reserved for future use. | 
| Returns | |
|---|---|
| boolean | trueif the request has been submitted successfully. | 
- Annotations
- Classes- CustomTabsCallback
- CustomTabsClient
- CustomTabsIntent
- CustomTabsIntent.Builder
- CustomTabsService
- CustomTabsServiceConnection
- CustomTabsSession
- CustomTabsSessionToken
- PostMessageService
- PostMessageServiceConnection
- R
- R.anim
- R.attr
- R.bool
- R.color
- R.dimen
- R.drawable
- R.id
- R.integer
- R.layout
- R.string
- R.style
- R.styleable
- TrustedWebUtils
 
