是否可以创建指向电子邮件应用程序的 imageview 链接?就像当您单击它时,电子邮件应用程序将打开并带有要发送的特定电子邮件地址?
问问题
333 次
2 回答
1
findViewById(R.id.imageview).setOnClickListener(new OnClickListener() {
public void onClick(View _) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.fromParts("mailto","abc@gmail.com", null));
startActivity(i);
}
}
于 2013-05-31T01:34:02.317 回答
1
img.setOnClickListener(
new OnClickListener(View v) {
String yourMail = "mail@example.com";
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{yourMail});
intent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
intent.putExtra(Intent.EXTRA_TEXT, "Your content");
try {
startActivity(intent, "Pick an email application...");
} catch(Exception e) {
Toast.makeText(YourMainActivity.this, "Have no email application!", Toast.LENGTH_SHORT).show();
}
}
);
于 2013-05-31T01:35:31.097 回答