我正在創建一個應用程序,其中有一個Gmail按鈕,當用戶點擊Gmail時,它會使用內置gmail客戶端向特定收件人發送郵件,但是當用戶點擊gmail按鈕時會發生什麼,打開設備中安裝的所有客戶端的列表,例如遠程登錄,驅動器,電子郵件,Gmail等,用戶請求選項。Android意圖選擇器
這裏是我的代碼
protected void sendEmail() {
Log.i("Send email", "");
String[] TO = {""};
String[] CC = {""};
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("message/rfc822"); //should i have to change this line of code
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_CC, CC);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject"); //message subject
emailIntent.putExtra(Intent.EXTRA_TEXT, "Email message goes here"); //message content
try {
startActivity(Intent.createChooser(emailIntent,"Send mail..."));
finish();
Log.i("Finished sending email.", "");
}
catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MailSenderActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
}
}
當用戶點擊它只是打開內置的Gmail和電子郵件客戶端只有不加息,所有的Gmail按鈕我想是。我怎麼能實現這個(通過改變類型或什麼?)。我嘗試了很多方法,但徒勞無功。
可能重複http://stackoverflow.com/questions/21800948/how-to-start-and-app-chooser –
L ook at http://stackoverflow.com/questions/3470042/intent-uri-to-launch-gmail-app – birraa
does not work ,, .. – neha