It's a simple tailor made app to provide a short-cut to Google Patents.
package com.example.googlepatents; import android.os.Bundle; import android.app.Activity; import android.view.Window; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { String GooglePatentsPath = "http://www.google.com/patents"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WebView webView = new WebView(this); getWindow().requestFeature(Window.FEATURE_PROGRESS); setContentView(webView); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); //enable JavaScript execution webSettings.setBuiltInZoomControls(true); //enable built-in zoom webSettings.setUseWideViewPort(true); //use the wide viewport webSettings.setLoadWithOverviewMode(true); //loads with overview mode webView.setWebViewClient(new MyWebViewClient()); webView.loadUrl(GooglePatentsPath); final Activity activity = this; webView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { activity.setProgress(progress * 100); }}); } public class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } }
Note: Permission of "android.permission.INTERNET" is needed.
No comments:
Post a Comment