WebView setWebChromeClient - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for WebView setWebChromeClient method.

This code example shows how to use the following methods:getSettings, loadUrl, setWebChromeClient, setWebViewClient
    mWebView = ((WebView) findViewById(R.id.webview));
    initWebView(); 
  } 
 
  private void initWebView() { 
    mWebView.setWebViewClient(new WebViewClient());
    mWebView.setWebChromeClient(new WebChromeClient());
    WebSettings settings = mWebView.getSettings();
    settings.setSavePassword(true);
    settings.setSaveFormData(true);
    settings.setJavaScriptEnabled(true);
    settings.setSupportZoom(false);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDomStorageEnabled(true);
    settings.setSupportMultipleWindows(false);
 
 
    mWebView.loadUrl("http://developer.android.com");
  } 
 

7
CodeRank
This code example shows how to use the following methods:getSettings, setWebChromeClient, setWebViewClient
This code example shows how to use the following methods:getSettings, loadUrl, setWebChromeClient, setWebViewClient
   
  @Override 
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_PROGRESS);
    webView = new WebView(this);
    setContentView(webView);
     
    cookieManager = CookieManager.getInstance();     
     
    initWebClient(); 
  } 
   
  private void initWebClient() { 
    webView.getSettings().setJavaScriptEnabled(true);
     
    webView.setWebChromeClient(new WebChromeClient() {
      public void onProgressChanged(WebView view, int progress) {
        // progress measures don't match web client progress measures 
        GoogleAuthActivity.this.setProgress(progress * 100);

7
CodeRank
This code example shows how to use the following methods:loadUrl, setWebChromeClient
 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		WebView view = new WebView(this);
		view.setWebChromeClient(new WebChromeClient() {
			public void onReceivedTitle(WebView view, String title) {
				HelpActivity.this.setTitle(title);
			} 
		}); 
		setContentView(view);
 
		view.loadUrl(getIntent().getData().toString());
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getSettings, loadUrl, setBackgroundColor, setWebChromeClient
 
	@SuppressLint("SetJavaScriptEnabled") 
	public static void displayArticle(WebView webView, Article article, Context context) {
		String styles = "iframe, img { width: 100%; }";
		if (isDarkTheme(context)) {
			webView.setBackgroundColor(Color.BLACK);
			styles += "body { background-color: #000000; color: #F6F6F6; } a { color: #0099FF; }";
		} 
		String html = String.format("<html><head><meta charset=\"utf-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"http://cdn.uservoice.com/stylesheets/vendor/typeset.css\"/><style>%s</style></head><body class=\"typeset\" style=\"font-family: sans-serif; margin: 1em\"><h3>%s</h3>%s</body></html>", styles, article.getTitle(), article.getHtml());
		webView.setWebChromeClient(new WebChromeClient());
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setPluginState(PluginState.ON);
		webView.loadUrl(String.format("data:text/html;charset=utf-8,%s", Uri.encode(html)));
	} 
 
    public static boolean isDarkTheme(Context context) {
        TypedValue tv = new TypedValue();
        float [] hsv =  new float[3];
        context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, tv, true);
        Color.colorToHSV(context.getResources().getColor(tv.resourceId), hsv);
7
CodeRank
This code example shows how to use the following methods:getSettings, loadUrl, setLayoutParams, setScrollBarStyle, setWebChromeClient
		getWindow().requestFeature(Window.FEATURE_PROGRESS);
 
		// Makes Progress bar Visible 
		getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
 
		WebView webView = new WebView(this);
		webView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.FILL_PARENT, 1f));
		webView.loadUrl(getIntent().getDataString());
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setSupportZoom(true);
		webView.getSettings().setBuiltInZoomControls(true);
//		webView.getSettings().setLoadWithOverviewMode(true); // not supported by older versions of Android 
		webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
		webView.getSettings().setUseWideViewPort(true);
 
		setContentView(webView);
		 
		webView.setWebViewClient(new WebViewClient() {
			@Override 

6
CodeRank
This code example shows how to use the following methods:getSettings, setWebChromeClient, setWebViewClient
This code example shows how to use the following methods:setWebChromeClient
            webView.setWebChromeClient(this);
        } else { 
            InstrumentationBackend.instrumentation.runOnMainSync(new Runnable() {
                @Override 
                public void run() { 
                    webView.setWebChromeClient(CalabashChromeClient.this);
                } 
            }); 
        } 
	} 
 
	@Override 
	public boolean onJsPrompt(WebView view, String url, String message,
			String defaultValue, JsPromptResult r) {
		if (message != null && message.startsWith("calabash:")) {
			r.confirm("CALABASH_ACK");
			System.out.println("onJsPrompt: " + message);
			String jsonResponse = message.replaceFirst("calabash:", "");
			scriptFuture.setResult(jsonResponse);			
			return true; 
6
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, getSettings, loadUrl, setLayoutParams, setWebChromeClient
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      //mWebView = (WebView) findViewById(R.id.webView); 
		mWebView = new WebView(this);
 
		mWebView.setLayoutParams(new LinearLayout.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		setContentView(mWebView);
		mWebView.loadUrl("file:///android_asset/www/index2.html");
		mWebView.getSettings().setJavaScriptEnabled(true);
		mWebView.addJavascriptInterface(new MyHybrid(), "MyHybrid");
		mWebView.setWebChromeClient(new WebChromeClient() {
			@Override 
			public void onConsoleMessage(String message, int lineNumber,
					String sourceID) {
				super.onConsoleMessage(message, lineNumber, sourceID);
			} 
		}); 
7
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, getSettings, loadUrl, setScrollBarStyle, setWebChromeClient
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        web = new WebView(this);
        web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
        setContentView(web);
         
        web.getSettings().setJavaScriptEnabled(true);
        web.getSettings().setAllowFileAccess(true);
        WebViewJavascriptInterface javascriptInterface = new WebViewJavascriptInterface();
        web.addJavascriptInterface(javascriptInterface, "android");
        web.setWebChromeClient(new WebChromeClient());
        web.setWebViewClient(new GenericWebViewClient());
         
        Intent intent = getIntent();
        String contentProviderBaseUri = intent.getStringExtra("base_uri");
        try { 
            server = new HttpServer(6789, "/explorer");

6
CodeRank

Related WebView setWebChromeClient Questions & Answers:

setWebChromeClient Method Overview
Sets the chrome handler.
See Code Examples for other Android WebView Methods: