Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

logcat

By: a guest on Jan 24th, 2011  |  syntax: None  |  size: 2.31 KB  |  hits: 756  |  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.Context;
  5. import android.content.Intent;
  6. import android.net.MailTo;
  7. import android.os.Bundle;
  8. import android.view.KeyEvent;
  9. import android.webkit.WebView;
  10. import android.webkit.WebViewClient;
  11.  
  12. public class mainActivity extends Activity {
  13.     /** Called when the activity is first created. */
  14.     /**@Override */
  15.     WebView webview;
  16.     public void onCreate(Bundle savedInstanceState) {
  17.         super.onCreate(savedInstanceState);
  18.         setContentView(R.layout.main);
  19.         webview = (WebView) findViewById(R.id.webview);
  20.         webview.setWebViewClient(new HelloWebViewClient());
  21.         webview.getSettings().setJavaScriptEnabled(true);
  22.         webview.loadUrl("http://www.cedarridge.cc");
  23.         }
  24.     @Override
  25.     public boolean onKeyDown(int keyCode, KeyEvent event) {
  26.         if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
  27.             webview.goBack();
  28.             return true;
  29.         }
  30.         return super.onKeyDown(keyCode, event);
  31.     }
  32.     private class HelloWebViewClient extends WebViewClient {
  33.         mWebClient = new WebViewClient(){
  34.  
  35.             @Override
  36.             public boolean shouldOverrideUrlLoading(WebView view, String url) {
  37.                 if(url.startsWith("mailto:")){
  38.                     MailTo mt = MailTo.parse(url);
  39.                     Intent i = IntentSupport.newEmailIntent(mainActivity.this, mt.getTo(), mt.getSubject(), mt.getBody(), mt.getCc());
  40.                     startActivity(i);
  41.                     view.reload();
  42.                     return true;
  43.                 }
  44.  
  45.                     else{
  46.                         view.loadUrl(url);
  47.                     }
  48.                     return true;
  49.                 }
  50.            };
  51.         mWebView.setWebViewClient(mWebClient);
  52.  
  53.         public static Intent newEmailIntent(Context context, String address, String subject, String body, String cc) {
  54.           Intent intent = new Intent(Intent.ACTION_SEND);
  55.           intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address });
  56.           intent.putExtra(Intent.EXTRA_TEXT, body);
  57.           intent.putExtra(Intent.EXTRA_SUBJECT, subject);
  58.           intent.putExtra(Intent.EXTRA_CC, cc);
  59.           intent.setType(MIME_TYPE_EMAIL);
  60.           return intent;
  61.     }
  62.     }}