You must have noticed that we are specifically keeping the package as " ", this is to ensure that only SMS application is targeted else it will show the other apps like clipboard, gdrive and bluetooth. This is explained below in the subsequent steps. The purpose of this intent is twofold - one is that we actually want the Messaging app to come up in the chooser dialog, and another one is that this will be used to create the ChooserIntent. The basic idea is as below:įirst of all, we create an intent with the action ACTION_SEND and type as " text/plain" in smsIntent. The method sendMesaage is written down to do the same. This tip describes how we accomplish this. But our intention was to show only messaging app and whatsapp app in this chooser. Just to iterate - Messaging, mail, notes, copy to clipboard, Google drive, Facebook, bluetooth are few of the applications that would be offered by chooser app to handle this intent. This all works very well, it will open up a number of applications which might be used for opening up this intent. What we do is that we create an Intent, set the action type as Intent.ACTION_SEND, set the type as " text/plain" and start the activity passing this intent. Since there are other text applications which have become popular, we might want to give an option of those applications also to the end user. In an Android application, suppose we want to send an SMS. This post aims to clearly explain what it is doing. You will find similar articles on the various platforms/blogs on the internet, but they do not explain clearly how it works. Here, we will focus on how to ensure that when a chooser dialog is opened up, you have only those applications that you want in it - not less not more. But that is not the scope of this article. Any application can register itself to handle or open up the URL and there is a way of doing it. In this case, the applications which are shown in the dialog happen to be all the browsers that you have in your device along with any other application which is registered to open up the URL of this kind.
The application which opens up this dialog is called Chooser Application. You must have seen in your Android devices, when you click on a URL that you have received in an SMS, mail or whatsapp message or from some other means, if there is more than one application which can open the URL, it opens up a dialog that asks you which application you want to open it up with.