0
是否有可能使imageview鏈接到電子郵件應用程序?就像當你點擊它時,電子郵件應用程序將打開一個特定的電子郵件地址發送?ImageView如何鏈接到電子郵件?
是否有可能使imageview鏈接到電子郵件應用程序?就像當你點擊它時,電子郵件應用程序將打開一個特定的電子郵件地址發送?ImageView如何鏈接到電子郵件?
findViewById(R.id.imageview).setOnClickListener(new OnClickListener() {
public void onClick(View _) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.fromParts("mailto","[email protected]", null));
startActivity(i);
}
}
img.setOnClickListener(
new OnClickListener(View v) {
String yourMail = "[email protected]";
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();
}
}
);
謝謝你,我的作品。 – user2438683