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

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

    I personally use:

    try {
        startActivity(i);
    } catch (ActivityNotFoundException e) {
        startActivity(Intent.createChooser(i, null));
    }
    

    So it will use default if user has default, will popup "no app" window if no app. Both are happy.

提交回复
热议问题