Set EXTRA_EMAIL in order to make email clients fill in email address

git-svn-id: https://zxing.googlecode.com/svn/trunk@1257 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-03-25 21:36:11 +00:00
parent 48a74e2b14
commit 9aef445f0e
2 changed files with 7 additions and 4 deletions

View file

@ -52,7 +52,7 @@ public final class EmailAddressResultHandler extends ResultHandler {
EmailAddressParsedResult emailResult = (EmailAddressParsedResult) getResult();
switch (index) {
case 0:
sendEmailFromUri(emailResult.getMailtoURI(), null, null);
sendEmailFromUri(emailResult.getMailtoURI(), emailResult.getEmailAddress(), null, null);
break;
case 1:
String[] addresses = new String[1];

View file

@ -206,16 +206,19 @@ public abstract class ResultHandler {
}
final void shareByEmail(String contents) {
sendEmailFromUri("mailto:", activity.getString(R.string.msg_share_subject_line), contents);
sendEmailFromUri("mailto:", null, activity.getString(R.string.msg_share_subject_line), contents);
}
final void sendEmail(String address, String subject, String body) {
sendEmailFromUri("mailto:" + address, subject, body);
sendEmailFromUri("mailto:" + address, address, subject, body);
}
// Use public Intent fields rather than private GMail app fields to specify subject and body.
final void sendEmailFromUri(String uri, String subject, String body) {
final void sendEmailFromUri(String uri, String email, String subject, String body) {
Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(uri));
if (email != null) {
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {email});
}
putExtra(intent, Intent.EXTRA_SUBJECT, subject);
putExtra(intent, Intent.EXTRA_TEXT, body);
intent.setType("text/plain");