In my android application I have implemented sending SMS by using below code.
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.putExtra("sms_body", "Hello World!");
smsIntent.putExtra("address", "0123456789");
smsIntent.setType("vnd.android-dir/mms-sms");
startActivity(smsIntent);
My problem is that if I have more than one SMS application on the device, it opens the chooser to choose the sender application. I don't want the chooser to be opened; I want to send from Android's native SMS app without opening the chooser. So any help to achieve this will be appreciated.
That is not the proper way to send SMS messages. Please use
ACTION_SEND
orACTION_SENDTO
(the latter with ansmsto:
Uri
). You may encounter devices which can send SMS messages but do not respond to the particularIntent
structure that you are using, since that is not the way to send SMS messages.If your user chose to install another SMS client, they have the right to use it, since it is their device, their SMS message fee, etc. The user can elect to make your app be the default for your
Intent
structure if the user chooses to do so, so the user will not be presented with the chooser all of the time.Different devices can have different "native SMS apps", put their by device manufacturers, so you have no means of determining what is the "native SMS app". And, as I noted earlier, the "native SMS app" may not even respond to that strange
Intent
structure that you are using.Use the SMS Manager?
http://developer.android.com/reference/android/telephony/SmsManager.html
Send a text based SMS.