Mailto on Android – ShiVa Engine

Mailto on Android

If you are experiencing problems with system.openURL() and non-hypertext protocols like mailto:, you can modify the ‘onOpenURL’ method in [yourGame].java and add something like this:

if(sURL.startsWith("mailto:")){
        MailTo mt = MailTo.parse(sURL);
        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());
        oThis.startActivity(i);
        //view.reload();
    } 

If you want the intent to target email applications only, use

intent.setType("message/rfc822");



Need more answers?

  • slackBanner