当前位置: 首页>>代码示例>>Java>>正文


Java AmazonJsPromptResult类代码示例

本文整理汇总了Java中com.amazon.android.webkit.AmazonJsPromptResult的典型用法代码示例。如果您正苦于以下问题:Java AmazonJsPromptResult类的具体用法?Java AmazonJsPromptResult怎么用?Java AmazonJsPromptResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AmazonJsPromptResult类属于com.amazon.android.webkit包,在下文中一共展示了AmazonJsPromptResult类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onJsPrompt

import com.amazon.android.webkit.AmazonJsPromptResult; //导入依赖的package包/类
/**
 * Tell the client to display a prompt dialog to the user.
 * If the client returns true, WebView will assume that the client will
 * handle the prompt dialog and call the appropriate JsPromptResult method.
 *
 * The prompt bridge provided for the InAppBrowser is capable of executing any
 * oustanding callback belonging to the InAppBrowser plugin. Care has been
 * taken that other callbacks cannot be triggered, and that no other code
 * execution is possible.
 *
 * To trigger the bridge, the prompt default value should be of the form:
 *
 * gap-iab://<callbackId>
 *
 * where <callbackId> is the string id of the callback to trigger (something
 * like "InAppBrowser0123456789")
 *
 * If present, the prompt message is expected to be a JSON-encoded value to
 * pass to the callback. A JSON_EXCEPTION is returned if the JSON is invalid.
 *
 * @param view
 * @param url
 * @param message
 * @param defaultValue
 * @param result
 */
@Override
public boolean onJsPrompt(AmazonWebView view, String url, String message, String defaultValue, AmazonJsPromptResult result) {
    // See if the prompt string uses the 'gap-iab' protocol. If so, the remainder should be the id of a callback to execute.
    if (defaultValue != null && defaultValue.startsWith("gap")) {
        if(defaultValue.startsWith("gap-iab://")) {
            PluginResult scriptResult;
            String scriptCallbackId = defaultValue.substring(10);
            if (scriptCallbackId.startsWith("InAppBrowser")) {
                if(message == null || message.length() == 0) {
                    scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
                } else {
                    try {
                        scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray(message));
                    } catch(JSONException e) {
                        scriptResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
                    }
                }
                this.webView.sendPluginResult(scriptResult, scriptCallbackId);
                result.confirm("");
                return true;
            }
        }
        else
        {
            // Anything else with a gap: prefix should get this message
            LOG.w(LOG_TAG, "InAppBrowser does not support Cordova API calls: " + url + " " + defaultValue); 
            result.cancel();
            return true;
        }
    }
    return false;
}
 
开发者ID:archriss,项目名称:inappbrowser-android,代码行数:59,代码来源:InAppChromeClient.java


注:本文中的com.amazon.android.webkit.AmazonJsPromptResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。