gpt4 book ai didi

java - Cordova 6.2.3 没有 WebChromeClient,我如何覆盖 onJsPrompt()?

转载 作者:太空宇宙 更新时间:2023-11-04 11:10:58 29 4
gpt4 key购买 nike

当我将项目从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;

扩展 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com