Java Code Examples for android.support.customtabs.CustomTabsService#RESULT_FAILURE_MESSAGING_ERROR

The following examples show how to use android.support.customtabs.CustomTabsService#RESULT_FAILURE_MESSAGING_ERROR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PostMessageHandler.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Relay a postMessage request through the current channel assigned to this session.
 * @param message The message to be sent.
 * @return The result of the postMessage request. Returning true means the request was accepted,
 *         not necessarily that the postMessage was successful.
 */
public int postMessage(final String message) {
    if (mChannel == null || !mChannel[0].isReady() || mChannel[0].isClosed()) {
        return CustomTabsService.RESULT_FAILURE_MESSAGING_ERROR;
    }
    ThreadUtils.postOnUiThread(new Runnable() {
        @Override
        public void run() {
            // It is still possible that the page has navigated while this task is in the queue.
            // If that happens fail gracefully.
            if (mChannel == null || mChannel[0].isClosed()) return;
            mChannel[0].postMessage(message, null);
        }
    });
    return CustomTabsService.RESULT_SUCCESS;
}
 
Example 2
Source File: PostMessageHandler.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Relay a postMessage request through the current channel assigned to this session.
 * @param message The message to be sent.
 * @return The result of the postMessage request. Returning true means the request was accepted,
 *         not necessarily that the postMessage was successful.
 */
public int postMessageFromClientApp(final String message) {
    if (mChannel == null || !mChannel[0].isReady() || mChannel[0].isClosed()) {
        return CustomTabsService.RESULT_FAILURE_MESSAGING_ERROR;
    }
    if (mWebContents == null || mWebContents.isDestroyed()) {
        return CustomTabsService.RESULT_FAILURE_MESSAGING_ERROR;
    }
    ThreadUtils.postOnUiThread(new Runnable() {
        @Override
        public void run() {
            // It is still possible that the page has navigated while this task is in the queue.
            // If that happens fail gracefully.
            if (mChannel == null || mChannel[0].isClosed()) return;
            mChannel[0].postMessage(message, null);
        }
    });
    return CustomTabsService.RESULT_SUCCESS;
}
 
Example 3
Source File: ClientManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
public synchronized int postMessage(CustomTabsSessionToken session, String message) {
    SessionParams params = mSessionParams.get(session);
    if (params == null) return CustomTabsService.RESULT_FAILURE_MESSAGING_ERROR;
    return params.postMessageHandler.postMessage(message);
}
 
Example 4
Source File: ClientManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public synchronized int postMessage(CustomTabsSessionToken session, String message) {
    SessionParams params = mSessionParams.get(session);
    if (params == null) return CustomTabsService.RESULT_FAILURE_MESSAGING_ERROR;
    return params.postMessageHandler.postMessageFromClientApp(message);
}