Ben*_*min 2 android android-intent android-5.0-lollipop
我一直在使用以下代码Intent在Android中启动发送电子邮件.在Android Lollipop(API级别21)之前,这个工作正常.不幸的是,在Android Lollipop中,这会引发"不支持的操作"错误.
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("message/rfc822");
intent.setData(Uri.parse("mailto:" + email));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
它非常基本,它只是通过电子邮件地址,让用户选择使用哪个应用程序.
我应该如何调整我的代码以使其在api级别上工作?我的最低API级别是16(JellyBean).
编辑 我已根据评论和答案包含MIME类型.