Only Email apps to resolve an Intent

后端 未结 14 1582
执念已碎
执念已碎 2020-12-03 06:30

I have a problem .. I want only email activities to resolve intent ACTION.SEND but beside email I get other apps as well (e.g TubeMate) even though I have set the mime type

14条回答
  •  时光说笑
    2020-12-03 07:16

    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);
    

    The point is to use ACTION_SENDTO as action and mailto: as data. If you want to let the user specify the destination email, use just mailto:; if you specify email yourself, use mailto:name@domain.com

    Suggested method filters all the application, that can send email(such as default email app or gmail)

提交回复
热议问题