Exemplo n.º 1
0
        protected override WebView CreateRefreshableView(Context context, IAttributeSet attrs)
        {
            WebView webView = base.CreateRefreshableView(context, attrs);

            // Need to add JS Interface so we can get the response back
            mJsCallback = new JsValueCallback(this);
            webView.AddJavascriptInterface(mJsCallback, JS_INTERFACE_PKG);

            return(webView);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Расширение WebView для выполнения скрипта  и получения результата.
        /// </summary>
        public static Task <object> ExJsWithResult(this WebView wv, string script)
        {
            var callback = new JsValueCallback();

            Application.SynchronizationContext.Post((obj) =>
            {
                wv.EvaluateJavascript(script, callback);
            }, null);
            //TODO Такой код лочит главный поток. Не знаю возможноно ли вообще это исправить, но желательно.
            return(callback.WaitValue());
        }
        //@Override
        protected override WebView createRefreshableView(Context context, IAttributeSet attrs)
        {
            WebView webView = base.createRefreshableView(context, attrs);

            // Need to add JS Interface so we can get the response back
            mJsCallback = new JsValueCallback(this);
            webView.AddJavascriptInterface(mJsCallback, JS_INTERFACE_PKG);

            return webView;
        }