"android.telephony.SmsManager" Class or "android.telephony.gsm.SmsManager" Class according to the SDK level of the device.
import java.lang.reflect.Method; import java.util.ArrayList; /** * This class implements the SMSSender interface, as defined in Common/DAL/SmsSenderI.h * * Reflection feature is used to manage "android.telephony.SmsManager" Class or * "android.telephony.gsm.SmsManager" Class according to the SDK level of the device. */ public class SmsSender { /** * @brief the sendSMS operation. * * The sendSMS operation sends an sms according to the address and the message itself. * * @param the address * @param the message */ public static int sendSMS(String sAddress, String sMessage) { int nRes = RMEError.ERMSuccess; try { Object oSmsManager; Method oGetDefaultMethod; Method oSendMultipartTextMessageMethod; Method oDivideMessageMethod; ArrayList<String> oDevideMessage; if(Globals.API_LEVEL >= 4) { oSmsManager = Class.forName("android.telephony.SmsManager"); } else { oSmsManager = Class.forName("android.telephony.gsm.SmsManager"); } oGetDefaultMethod = ((Class)oSmsManager).getMethod("getDefault", (Class[]) null); oSendMultipartTextMessageMethod = ((Class)oSmsManager).getMethod("sendMultipartTextMessage", new Class[] {String.class, String.class, ArrayList.class, ArrayList.class, ArrayList.class}); oDivideMessageMethod = ((Class)oSmsManager).getMethod("divideMessage", new Class[] {String.class}); oSmsManager = oGetDefaultMethod.invoke(oSmsManager); oDevideMessage = (ArrayList<String>)oDivideMessageMethod.invoke(oSmsManager, sMessage); oSendMultipartTextMessageMethod.invoke(oSmsManager, sAddress, null, oDevideMessage, null, null); } catch (Exception e) { } return nRes; } }