Code example for WebView: Displaying web pages

Methods: addJavascriptInterfacegetSettingsloadUrlsetBackgroundColorsetInitialScalesetWebViewClient, setBackgroundDrawable, setBackgroundResource, setClickable, setFocusable

0
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
 
    browser = (WebView)findViewById(R.id.webkit);
 
    browser.getSettings().setDefaultTextEncodingName("utf-8");
    browser.getSettings().setSupportZoom(false);
    browser.getSettings().setBuiltInZoomControls(false);
    browser.getSettings().setLightTouchEnabled(false);
    browser.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    browser.getSettings().setSupportMultipleWindows(false);
    browser.getSettings().setDomStorageEnabled(true);
    browser.getSettings().setAppCacheMaxSize(1024*1024*10);
    browser.getSettings().setAllowFileAccess(true);
     
    browser.setHorizontalScrollBarEnabled(false);
    browser.setVerticalScrollBarEnabled(false);   
 
    browser.setClickable(true);
    browser.setFocusable(true);
    browser.setFocusableInTouchMode(true);
    browser.setInitialScale(0);
     
    browser.setBackgroundColor(Color.TRANSPARENT);
    browser.setBackgroundDrawable(null);
    browser.setBackgroundResource(0);
     
    browser.getSettings().setJavaScriptEnabled(true);
 
    // myJson = httpGet("http://cwadserver-stage.herokuapp.com/?zone=162"); 
 
    // myJson = "clickwall.viewParams = {\"Root\": \"http://s3.amazonaws.com/assets.stage.clickwall.com/\",\"Color_0\": \"#2c13cf\",\"Color_1\": \"#f7f7ef\",\"Color_2\": \"#6dd183\",\"Color_3\": \"#ffffff\"};"; 
    browser.addJavascriptInterface(new Info(), "info");
     
    browser.setWebViewClient(new WebClient() {
      @Override   
      public void onPageFinished(WebView view, String url) {
        // browser.loadUrl("javascript:clickwall.doSomething('hahaha2')"); 
        // browser.loadUrl("javascript:$('#msg').html('manipulating from app using jquery')"); 
        // browser.loadUrl("javascript:$('#msg').html('" + myJson + "');$('#msg').prepend('<p>blablabla</p>')"); 
        browser.loadUrl("javascript:clickwall.doMagic()");
      } 
    }); 
    browser.loadUrl("http://s3.amazonaws.com/simon.clickwall.dev/mobile/v0.4/boris-style.html");
  } 
 
 
  @Override 
  public void onResume() { 
Stop searching for code, let great code find you!  Add Codota to your java IDE