当前位置: 首页>>代码示例>>Java>>正文


Java WebView.evaluateJavascript方法代码示例

本文整理汇总了Java中android.webkit.WebView.evaluateJavascript方法的典型用法代码示例。如果您正苦于以下问题:Java WebView.evaluateJavascript方法的具体用法?Java WebView.evaluateJavascript怎么用?Java WebView.evaluateJavascript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.evaluateJavascript方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPageFinished

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onPageFinished(WebView view, String url) {
	if (view.isShown()) {
		mBrowserController.updateUrl(url, true);
		view.postInvalidate();
	}
	if (view.getTitle() == null || view.getTitle().isEmpty()) {
		mTitle.setTitle(mActivity.getString(R.string.untitled));
	} else {
		mTitle.setTitle(view.getTitle());
	}
	if (API >= android.os.Build.VERSION_CODES.KITKAT && mInvertPage) {
		view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
	}
	mBrowserController.update();
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:17,代码来源:LightningView.java

示例2: onPageFinished

import android.webkit.WebView; //导入方法依赖的package包/类
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);

    final String password = profile.getString("password", null);
    final String username = profile.getString("username", null);
    if(profile.getString("username",null).equals("default") || profile.getString("password",null).equals("default"))
    {
        Toast.makeText(getApplicationContext(),"Enter your login details properly !",Toast.LENGTH_LONG).show();
        Intent log = new Intent(Moodle.this,LoginActivity.class);
        startActivity(log);
        return;
    }
    final String js = "javascript:" +
            "document.getElementById('password').value = '" + password + "';" +
            "document.getElementById('username').value = '" + username + "';" +
            "document.getElementById('loginbtn').click()";
    if (Build.VERSION.SDK_INT >= 19) {
        view.evaluateJavascript(js, new ValueCallback<String>() {
            @Override
            public void onReceiveValue(String s) {

            }
        });
    } else {
        view.loadUrl(js);
    }

}
 
开发者ID:ashutoshbsathe,项目名称:COEP-Moodle-via-Webview,代码行数:30,代码来源:Moodle.java

示例3: myEvaluateJavaScript

import android.webkit.WebView; //导入方法依赖的package包/类
private void myEvaluateJavaScript(WebView webView, String script) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        webView.evaluateJavascript(script, null);
    } else {
        webView.loadUrl("javascript:" + script);
    }
}
 
开发者ID:akhilkedia,项目名称:AllTrans,代码行数:8,代码来源:WebViewHookHandler.java

示例4: stopAndStartVideos

import android.webkit.WebView; //导入方法依赖的package包/类
private void stopAndStartVideos(WebView oldView, WebView currentView){
    // Selects the first (and presumably only) video on the page if any exists
    String videoSelector = "document.getElementsByTagName('video')[0]";

    if(oldView != null)
        oldView.evaluateJavascript(videoSelector + ".pause();", null);
    if(currentView != null)
        currentView.evaluateJavascript(videoSelector + ".play();", null);
}
 
开发者ID:BloomBooks,项目名称:BloomReader,代码行数:10,代码来源:ReaderActivity.java

示例5: invoke

import android.webkit.WebView; //导入方法依赖的package包/类
public void invoke(WebView webView, ValueCallback<String> callback) {
    if (webView == null)
        return;
    if (!mJsFuncSign.startsWith(JS_FUNC_PREFIX)) {
        mJsFuncSign = JS_FUNC_PREFIX + mJsFuncSign;
    }
    // api 19
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && callback != null) {
        webView.evaluateJavascript(mJsFuncSign, callback);
    } else {
        webView.loadUrl(mJsFuncSign);
    }
}
 
开发者ID:chendongMarch,项目名称:uikit,代码行数:14,代码来源:JsFunction.java

示例6: onPageFinished

import android.webkit.WebView; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onPageFinished(@NonNull WebView view, String url) {
    if (view.isShown()) {
        mUIController.updateUrl(url, false);
        mUIController.setBackButtonEnabled(view.canGoBack());
        mUIController.setForwardButtonEnabled(view.canGoForward());
        view.postInvalidate();
    }
    if (view.getTitle() == null || view.getTitle().isEmpty()) {
        mLightningView.getTitleInfo().setTitle(mActivity.getString(R.string.untitled));
    } else {
        mLightningView.getTitleInfo().setTitle(view.getTitle());
    }
    if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT &&
        mLightningView.getInvertePage()) {
        view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
    }
    mUIController.tabChanged(mLightningView);
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:21,代码来源:LightningWebClient.java

示例7: inject

import android.webkit.WebView; //导入方法依赖的package包/类
private void inject(WebView view, String script, ValueCallback<String> callback) {
    view.evaluateJavascript(script, callback);
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:4,代码来源:InjectableWebClient.java

示例8: injection

import android.webkit.WebView; //导入方法依赖的package包/类
private void injection(WebView webView) {
//        Log.d("TTT_d", "injection - " + currVideoId);
        if (TextUtils.isEmpty(currVideoId) == true) {
            return;
        }

        if (Build.VERSION.SDK_INT >= 19) {
            webView.evaluateJavascript(rawJS, null);
        } else {
            webView.loadUrl("javascript:" + rawJS);
        }
    }
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:13,代码来源:YoutubeSmingActivity.java

示例9: evalJS

import android.webkit.WebView; //导入方法依赖的package包/类
/**
 * Evaluates JavaScript code in an API-level independent way.
 *
 * Note: all WebView methods must be called from the UIThread.
 */
@UiThread
static void evalJS(final WebView webView, final String script) {
    // implementation via http://stackoverflow.com/a/30828985/
    if (Build.VERSION.SDK_INT >= 19) {
        webView.evaluateJavascript(script, null);
    } else {
        webView.loadUrl("javascript:" + script);
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:15,代码来源:WebViewUtils.java

示例10: initWebView

import android.webkit.WebView; //导入方法依赖的package包/类
private void initWebView() {
        wvWeb = (WebView) findViewById(R.id.wv_web);
        wvWeb.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                if (newProgress == 100) {
                    fl.setVisibility(View.GONE);
                    url = wvWeb.getUrl();
                } else {
                    fl.setVisibility(View.VISIBLE);
                }
            }
        });

        wvWeb.setWebViewClient(new WebViewClient());
        wvWeb.getSettings().setBuiltInZoomControls(false);
        wvWeb.getSettings().setJavaScriptEnabled(true);
        wvWeb.getSettings().setDomStorageEnabled(true);
        wvWeb.getSettings().setDatabaseEnabled(true);
//        wvWeb.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        wvWeb.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);  //设置 缓存模式
        String cacheDirPath = getFilesDir().getAbsolutePath();
        //      String cacheDirPath = getCacheDir().getAbsolutePath()+Constant.APP_DB_DIRNAME;
        //设置数据库缓存路径
        wvWeb.getSettings().setDatabasePath(cacheDirPath);
        //设置  Application Caches 缓存目录
        wvWeb.getSettings().setAppCachePath(cacheDirPath);
        wvWeb.getSettings().setAppCacheEnabled(true);


        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            Log.i("log", "initWebView: --------------  1");
            wvWeb.evaluateJavascript("document.body.style.backgroundColor=\"black\";document.body.style.color=\"white\";", null);
        } else {
            Log.i("log", "initWebView: --------------  2");
            wvWeb.loadUrl("javascript:document.body.style.backgroundColor=\"#black\";document.body.style.color=\"white\";");
        }
        wvWeb.loadUrl(url);



    }
 
开发者ID:lueans,项目名称:LueansRead,代码行数:44,代码来源:WebActivity.java


注:本文中的android.webkit.WebView.evaluateJavascript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。