0

i have a document which is loaded in webViewActivity, in this document i have my email id. when users clicks my email id i want to open email app, please help me.

This is sample document. 
          This is text contained in document. if you have any queries please contact me at mailto@examplemail.com 
Venkat
  • 232
  • 3
  • 11
  • Please check this: http://stackoverflow.com/questions/9387999/how-to-open-webview-link-to-new-activity –  Oct 28 '13 at 11:34
  • maybe the solution is here: http://stackoverflow.com/questions/2197741/how-to-send-email-from-my-android-application – ƒernando Valle Oct 28 '13 at 11:34

1 Answers1

2

Try this :

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

         //Check whether url contains email or not.
        // To start Email Intent

        String[] mailto = { "example.com" };

    // Create a new Intent to send messages
    Intent sendIntent = new Intent(Intent.ACTION_SEND);

    // Add attributes to the intent
    sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, "This is sample document.");

    sendIntent.setType("message/rfc822");
    startActivity(sendIntent);


        return true;

    }

Hope this helps.

Siddharth_Vyas
  • 9,972
  • 10
  • 39
  • 69
  • Thanks for your valuable help. but i got error like this - The method startActivity(Intent) is undefined for the type MyWebViewClient – Venkat Oct 28 '13 at 11:45
  • Thanks i got solution by adding view.getContext().startActivity(sendIntent); – Venkat Oct 28 '13 at 11:54