1

How to get value in method asynchronous

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);

}

How to get "value" of method getDataVebview in method getGetDataByUrl ??

NPBA
  • 129
  • 1
  • 2
  • 9
  • Use asyncTask.. better learn about http://stackoverflow.com/questions/9671546/asynctask-android-example – karan Jul 23 '16 at 03:59

0 Answers0