如何在webview中获得价值

时间:2016-07-23 03:31:53

标签: android android-webview

如何在方法异步中获取值

public void getGetDataByUrl(String url) {
            MainActivity.getInstance().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                  getDataVebview(url);
                }
            });
}

boolean isPageMediaFinished = false;

 @SuppressLint("JavascriptInterface")
    public void getDataVebview(String url) {
        _webView = new WebView(MainActivity.getInstance());
        _webView.getSettings().setJavaScriptEnabled(true);
        WebAppInterface webAppInterface = new WebAppInterface(MainActivity.getInstance());
        _webView.addJavascriptInterface(webAppInterface, Constant.WEBAPP_JSI);
        isPageMediaFinished = false;
        _webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {

                if (isPageMediaFinished){
                    return;
                }

                isPageMediaFinished = true;

                    _webView.evaluateJavascript(Constant.GET_JSI_URL, new ValueCallback<String>() {
                        @Override
                        public void onReceiveValue(String value) {
                            if(value != null) {
                 //How to get data value in method setGetData
                            }
                        }
                    });
            }
        });
        _webView.loadUrl(url);

}

如何获得&#34;价值&#34; getGetDataByUrl方法中方法getDataVebview的方法

0 个答案:

没有答案