当我将项目从Cordova 3更新到Cordova 6时,我发现没有WebChromeClient,但是我的项目使用了该类并覆盖了onJsPrompt()。
现在,我应该如何基于Cordova 6重写OnJsPrompt()


package com.qtby.gxwlc;import org.apache.cordova.CordovaChromeClient;import org.apache.cordova.CordovaInterface;import org.apache.cordova.CordovaWebView;import com.jsdemo.ClientTool;import com.jsdemo.JsNativeFunc;import android.content.Intent;import android.webkit.JsPromptResult;import android.webkit.WebView;public class CustomerWebChromeClient extends CordovaChromeClient { public CustomerWebChromeClient(CordovaInterface ctx, CordovaWebView app){ super(ctx, app); } JsNativeFunc jsNativeFunc; public JsNativeFunc getJsNativeFunc(){ return jsNativeFunc; } public boolean isJsNativeFunc(int requestCode){ if(jsNativeFunc == null) return false; return jsNativeFunc.isJsNativeFunc(requestCode); } public void jsResult(int requestCode, int resultCode, Intent intent){ jsNativeFunc.jsResult(requestCode, resultCode, intent); } @Override public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, JsPromptResult result) { if(ClientTool.callNativeFunc(message)){ return super.onJsPrompt(view, origin, message, defaultValue, result); } return true; } return super.onJsPrompt(view, origin, message, defaultValue, result); }}

最佳答案

您现在就执行此操作。

import org.apache.cordova.engine.SystemWebChromeClient;


extends SystemWebChromeClient

https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java

干杯

关于java - Cordova 6.2.3没有WebChromeClient,如何覆盖onJsPrompt()?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46001837/

10-10 09:47