Opening an email client on clicking a button

前端 未结 6 1871
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 06:01

I am designing an app in which i need to open an email client on clicking a button. The email client should be opened with a pre-defined subject and \'to\' address. Is there

6条回答
  •  悲&欢浪女
    2020-12-13 06:42

    Ok - now the above answer no longer works for me in year 2020. I found something mentioned on google official developer sites which worked for me.

     Intent intent = new Intent(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:")); // only email apps should handle this
        intent.putExtra(Intent.EXTRA_EMAIL, addresses);
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }
    

提交回复
热议问题