2013-10-28 62 views
0

我有一個在webViewActivity中加載的文檔,在這個文檔中我有我的電子郵件ID。當用戶點擊我的電子郵件ID我想打開電子郵件應用程序,請幫助我。如何發送來自webviewActivity的郵件android

This is sample document. 
      This is text contained in document. if you have any queries please contact me at [email protected] 
+0

請檢查此:http://stackoverflow.com/questions/9387999/how-to-open-webview-link-to-new-activity – Nostradamus

+0

也許解決方法是在這裏:http://stackoverflow.com/questions/2197741/how-to-send-email-from-my-android-application –

回答

2

試試這個:

@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; 

    } 

希望這有助於。

+0

感謝您的寶貴幫助。但我得到這樣的錯誤 - 方法startActivity(意圖)是未定義的類型MyWebViewClient – Venkat

+0

您可以請添加您的代碼。 –

+0

謝謝我通過添加view.getContext()。startActivity(sendIntent); – Venkat