public interface

PostMessageBackend

 androidx.browser.customtabs.PostMessageBackend

Subclasses:

PostMessageServiceConnection

Gradle dependencies

compile group: 'androidx.browser', name: 'browser', version: '1.4.0'

  • groupId: androidx.browser
  • artifactId: browser
  • version: 1.4.0

Artifact androidx.browser:browser:1.4.0 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.browser:browser com.android.support:customtabs

Overview

Abstracts a receiver of postMessage events. For example, this could be a service connection like PostMessageServiceConnection or it could be a local client.

This will always be backed by a class on the provider side rather than the client side. However, in the case of PostMessageServiceConnection, it will defer to the client by making remote calls.

Summary

Methods
public voidonDisconnectChannel(Context appContext)

Notifies the client that the channel has been disconnected.

public booleanonNotifyMessageChannelReady(Bundle extras)

Notifies the client that the postMessage channel is ready to be used.

public booleanonPostMessage(java.lang.String message, Bundle extras)

Posts a message to the client.

Methods

public boolean onPostMessage(java.lang.String message, Bundle extras)

Posts a message to the client.

Parameters:

message: The String message to post.
extras: Unused.

Returns:

Whether the postMessage was sent successfully.

public boolean onNotifyMessageChannelReady(Bundle extras)

Notifies the client that the postMessage channel is ready to be used.

Parameters:

extras: Unused.

Returns:

Whether the notification was sent successfully.

public void onDisconnectChannel(Context appContext)

Notifies the client that the channel has been disconnected.

Parameters:

appContext: The application context.

Source

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.browser.customtabs;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;

/**
 * Abstracts a receiver of postMessage events. For example, this could be a service connection like
 * {@link PostMessageServiceConnection} or it could be a local client.
 *
 * <p>This will always be backed by a class on the provider side rather than the client side.
 * However, in the case of {@link PostMessageServiceConnection}, it will defer to the client by
 * making remote calls.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
public interface PostMessageBackend {

    /**
     * Posts a message to the client.
     * @param message The String message to post.
     * @param extras Unused.
     * @return Whether the postMessage was sent successfully.
     */
    boolean onPostMessage(@NonNull String message, @Nullable Bundle extras);

    /**
     * Notifies the client that the postMessage channel is ready to be used.
     * @param extras Unused.
     * @return Whether the notification was sent successfully.
     */
    boolean onNotifyMessageChannelReady(@Nullable Bundle extras);

    /**
     * Notifies the client that the channel has been disconnected.
     * @param appContext The application context.
     */
    void onDisconnectChannel(@NonNull Context appContext);
}