scu*_*uba 13 email android android-intent android-activity
我试过这个代码,我在这里找到:
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "testemail@gmail.com", null)); startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
但是我在屏幕上看到一条消息,上面写着"不支持的动作".有关如何使其工作的任何想法?
谢谢!
Com*_*are 27
试试这个片段:
/* Create the Intent */
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
/* Fill it with Data */
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"to@email.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Text");
/* Send it off to the Activity-Chooser */
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Run Code Online (Sandbox Code Playgroud)
关键部分:EXTRA_EMAIL用于您的地址并createChooser()在用户配置了多个电子邮件客户端的情况下使用.
你试过了吗
Intent intent = new Intent(
Intent.ACTION_SENDTO,
Uri.parse("mailto:testemail@gmail.com")
);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6172 次 |
| 最近记录: |