小编joa*_*rso的帖子

使用Android中的Cordova 5.0构建自定义WebView

我想用Cordova构建一个自定义WebView.为此,我想覆盖setWebChromeClient和setWebViewClient方法.但是为此我需要一个SystemWebViewClient,它需要一个SystemWebViewEngine,我现在似乎无法得到它.这是我的主要活动

public class MyActivity extends CordovaActivity implements CordovaInterface {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        int threadSize = getResources().getInteger(R.integer.WIPThreadPoolSize);

        // Initiate Thread pool
        threadPool = new ThreadPoolExecutor(threadSize, threadSize, 10, TimeUnit.SECONDS, this.priorityQueue);

        initApplicationInformationManager();

        // initialize global variables
        GlobalApplicationVariables.initValues(this);

        isActivityReady = false;

        isActivityReady = false;

        setContentView(R.layout.main_layout);
        super.init();

    }


    protected CordovaWebView makeWebView() {

        SystemWebView webView = (SystemWebView) findViewById(R.id.customWebView);
       SystemWebViewEngine engine = new SystemWebViewEngine(webView);


        return new CordovaWebViewImpl(engine);
    }

   protected void createViews() {
        appView.getView().requestFocusFromTouch();
    }
}
Run Code Online (Sandbox Code Playgroud)

我的自定义webview:

@SuppressLint("SetJavaScriptEnabled")
public class CustomWebView extends SystemWebView {

    private …
Run Code Online (Sandbox Code Playgroud)

android android-webview cordova cordova-5.0.0

5
推荐指数
1
解决办法
1515
查看次数

标签 统计

android ×1

android-webview ×1

cordova ×1

cordova-5.0.0 ×1