Messaging and email intents in Android?

2019-03-02 02:42发布

I've searched Google for this, but have only found similar examples--not exactly what I need. I simply need to start messaging (SMS) and email intents from my app with their "to" fields already populated. So I need to send a number with the sms intent and an email address with the email intent. Any help would be appreciated.

2条回答
Rolldiameter
2楼-- · 2019-03-02 03:21

For the e-mail part :

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"foo@bar.com"});

emailIntent.setType("text/plain");
startActivity(Intent.createChooser(emailIntent, "Send a mail ..."));
查看更多
冷血范
3楼-- · 2019-03-02 03:29

from Only Email apps to resolve an Intent

   String recepientEmail = ""; // either set to destination email or leave empty
   Intent intent = new Intent(Intent.ACTION_SENDTO);
   intent.setData(Uri.parse("mailto:" + recepientEmail));
   startActivity(intent);

will filter out all non-email applications.

查看更多
登录 后发表回答