Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

logcat

By: a guest on Jan 24th, 2011  |  syntax: None  |  size: 1.71 KB  |  views: 375  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.apps.jerdog.crcc;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.net.MailTo;
  6. import android.os.Bundle;
  7. import android.view.KeyEvent;
  8. import android.webkit.WebView;
  9. import android.webkit.WebViewClient;
  10.  
  11. public class mainActivity extends Activity {
  12.     /** Called when the activity is first created. */
  13.     /**@Override */
  14.     WebView webview;
  15.     public void onCreate(Bundle savedInstanceState) {
  16.         super.onCreate(savedInstanceState);
  17.         setContentView(R.layout.main);
  18.         webview = (WebView) findViewById(R.id.webview);
  19.         webview.setWebViewClient(new HelloWebViewClient());
  20.         webview.getSettings().setJavaScriptEnabled(true);
  21.         webview.loadUrl("http://www.cedarridge.cc");
  22.         }
  23.     @Override
  24.     public boolean onKeyDown(int keyCode, KeyEvent event) {
  25.         if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
  26.             webview.goBack();
  27.             return true;
  28.         }
  29.         return super.onKeyDown(keyCode, event);
  30.     }
  31.     private class HelloWebViewClient extends WebViewClient {
  32.         @Override
  33.         public boolean shouldOverrideUrlLoading(WebView view, String url) {
  34.             if(url.startsWith("mailto:")){
  35.                 MailTo mt = MailTo.parse(url);
  36.                 Intent i = IntentSupport.newEmailIntent(mainActivity.this, mt.getTo(), mt.getSubject(), mt.getBody(), mt.getCc());
  37.                 startActivity(i);
  38.                 view.reload();
  39.                 return true;
  40.             }
  41.  
  42.                 else{
  43.                     view.loadUrl(url);
  44.                 }
  45.                 return true;
  46.             }
  47.         };
  48.         mWebView.setWebViewClient(mWebClient);        }
  49.     }}