开发者

how to call email application in android platform

开发者 https://www.devze.com 2022-12-13 01:34 出处:网络
there is an intent for “send an email.开发者_运维百科” In our application needs to send mail, how can invoke that intentYou can\'t send an email directly without using a hacked version of the javama

there is an intent for “send an email.开发者_运维百科” In our application needs to send mail, how can invoke that intent


You can't send an email directly without using a hacked version of the javamail apis, but you can easily have the user send one for you using Intent.ACTION_SEND and an Intent Chooser.

final Intent emailIntent = new Intent(Intent.ACTION_SEND); 
emailIntent.setType("text/plain"); 
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"webmaster@website.com"}); 
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "my subject"); 
emailIntent.putExtra(Intent.EXTRA_TEXT, "body text"); 
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));

Make sure you're on an actual device when you test this code as it won't work from within the emulator.

0

精彩评论

暂无评论...
验证码 换一张
取 消