Search code examples
androidsmsandroid-implicit-intent

Sending a SMS Message from an Android Application without opening chooser?


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.


Solution

  • Use the SMS Manager?

    http://developer.android.com/reference/android/telephony/SmsManager.html

    void    sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
    

    Send a text based SMS.