Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art
Sending Single-Part or Multipart SMS MessagesBack to Android Cookbook Home | Up to Chapter: Telephone Applications

Author: Colin Wilcox ('NavaronUK')
In Published Edition? Yes
FormatLanguage: WikiFormat

Sending Single-Part or Multipart SMS Messages


A simple way to send either a single part or a multipart (handing the message concatenation UDH) from a single entry point


Use the SMSManager.


public class SendSMS
	SMSManager iSMSManager = null;
	ArrayList<String> iFragmentList = null;

	SendSMS ()
		iSMSManager = SMSManager.getDefault ();

	public boolean sendSMSMessage (String aDestination, String aMessageText)
		if (iSMSManager == null)
			return (false);
                  int fragmentCount = 0;
		iFragmentList = iSMSManager.divideMessage (aMessageText);
		fragmentCount = iFragmentList.Count ();
		if (fragmentCount > 1)
			iSMSManager.SendMultipartMessage (aDestinationAddress, null, iFragmentList, null, null, null);
			iSMSManager.SendTextMessage (aDestinationAddress, null, aMessageText, null, null, null);
		return true;	

// end of file

See Also


The source code for this project is in the Android Cookbook repository, http://github.com/IanDarwin/Android-Cookbook-Examples/tree/master/SendSMS