Jul 15, 2012

Tailor made app for Google Patents Search with WebView

Google provide a nice service, Google Patents (http://www.google.com/patents). With Google Patents, you can now search the full text of the U.S. patent corpus and find patents that interest you.

It's a simple tailor made app to provide a short-cut to Google Patents.

Google Patents Search


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

Infolinks In Text Ads