-1

mailto: doesn't work in my app (webview) , it works ok in my web site. what can I do ? Thanks

public class MainActivity extends AppCompatActivity {
public WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    myWebView = (WebView)findViewById(R.id.webView);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    myWebView.getSettings().setBuiltInZoomControls(true);
    myWebView.getSettings().setDisplayZoomControls(false);
    myWebView.loadUrl("http://www.1234.com");
    myWebView.setWebViewClient(new WebViewClient());

}
Amit
  • 3
  • 3

1 Answers1

0

You may create custom web client with shouldOverrideUrlLoading and put code:

if(url.startsWith("mailto:")){
    MailTo mt = MailTo.parse(url);
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_EMAIL, new String[]{mt.getTo()});
    i.putExtra(Intent.EXTRA_SUBJECT, mt.getSubject());
    i.putExtra(Intent.EXTRA_CC, mt.getCc());
    i.putExtra(Intent.EXTRA_TEXT, mt.getBody());
    mContext.startActivity(i);
    view.reload();
    return true;
} 

Read this question for more details