Code example for WebView: Displaying web pages

Methods: getSettingsloadUrlsetWebChromeClientsetWebViewClient, setDownloadListener

0
 
            getWindow().requestFeature(Window.FEATURE_PROGRESS); 
            setContentView(R.layout.webview); 
            myweb = (WebView) findViewById(R.id.webView1); 
 
            myweb.setWebViewClient(new HelloWebViewClient()); 
 
            myweb.setWebChromeClient(new WebChromeClient() { 
                    @Override  
                    public void onProgressChanged(WebView view, int progress) { 
                            // Activities and WebViews measure progress with different  
                            // scales.  
                            // The progress meter will automatically disappear when we reach  
                            // 100%  
                            activity.setProgress(progress * 100); 
                    }  
 
            });  
            myweb.setDownloadListener(new DownloadListener() { 
            /* (non-Javadoc)  
             * @see  
android.webkit.DownloadListener#onDownloadStart(java.lang.String,  
java.lang.String, java.lang.String, java.lang.String, long)  
             */  
            public void onDownloadStart(String url, String userAgent, 
                    String contentDisposition, String mimetype, 
                    long contentLength) { 
                downloadfileto(url, "/sdcard/test.mp3"); 
 
            }  
        });  
            Toast.makeText(this, "Please wait", 
                            Toast.LENGTH_LONG).show(); 
 
            myweb.loadUrl("http://www.mp3.zing.vn" +
            		"");  
 
            myweb.getSettings().setJavaScriptEnabled(true); 
 
            myweb.getSettings().setPluginsEnabled(true); 
            myweb.getSettings().setBuiltInZoomControls(true); 
 
            SharedPreferences settings = getSharedPreferences("MyPrefsFile", 0); 
            isfirsttime = settings.getBoolean("isfirsttime", false); 
            if (isfirsttime) { 
                    SharedPreferences.Editor editor = settings.edit(); 
Connect your IDE to all the code out there  Get Codota for Java