Kar*_*mil 4 email android sendto android-activity
我想从我的应用发送一封电子邮件.所以我使用了以下代码.
String uriText = "abcd@gmail.com" + "?subject=" + URLEncoder.encode("Subject") + "&body=" + URLEncoder.encode("some text here");
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send Email"));
Run Code Online (Sandbox Code Playgroud)
我已经配置了Gmail和电子邮件应用程序.我测试了我的Nexus S(JellyBean)和HTC T-Mobile G2(GingerBread).它们都显示"没有应用可以执行此操作."
有没有人知道这里有什么问题?
如果您Intent.setData 用于发送电子邮件,请将您的代码更改为:
String uriText = "mailto:someone@example.com" +
"?subject=" + URLEncoder.encode("Subject") +
"&body=" + URLEncoder.encode("some text here");
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send Email"));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3342 次 |
| 最近记录: |