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

前端 未结 5 2318
死守一世寂寞
死守一世寂寞 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:58

    AFAIK, if you use Intent.createChooser, there are three differences:

    1. You can specify the title of the chooser dialog to make it more clear.

    2. The system will always present the chooser dialog even if the user has chosen a default one.

    3. If your intent created by Intent.createChooser doesn't match any activity, the system will still present a dialog with the specified title and an error message No application can perform this action. Or for the normal intent, you may get an Android runtime error with: Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent

提交回复
热议问题