What is the purpose of using Intent.createChooser() in StartActivity() while sending email in Android

前端 未结 5 2319
死守一世寂寞
死守一世寂寞 2020-12-15 16:11

When ever we need to send an email in Android we will invoke registered email application using Intent.ACTION_SEND like below

Intent i = new Intent(Intent.AC         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 16:52

    Way old message but for others who come across it, you can set the type on the Intent to the mime type of emails, which will at least limit it to applications that can send that appropriate type of message:

    Intent i = new Intent(Intent.ACTION_SEND); 
    i.setType( "message/rfc822");
    startActivity(Intent.createChooser(i, "Send mail..."));
    

    Makes the chooser dialog much cleaner.

提交回复
热议问题