Правильный способ сделать это - использовать sendDataMessage из класса SmsManager.Вот маленький код (SMSSender):
SmsManager smsMgr = SmsManager.getDefault();
smsMgr.sendDataMessage(phoneNumber, null,
(short) myApplicationPort, messageString.getBytes(), sentIntent, deliveryIntent);
Вот еще один маленький код (SMSReceiver):
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdusObj = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdusObj.length];
// getting SMS information from PDU
for (int i = 0; i < pdusObj.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
}
for (SmsMessage currentMessage : messages) {
if (!currentMessage.isStatusReportMessage()) {
String messageBody = currentMessage.getDisplayMessageBody();
byte[] messageByteArray = currentMessage.getPdu();
// skipping PDU header, keeping only message body
int x = 1 + messageByteArray[0] + 19 + 7;
// I'm not sure about this last line, as I'm not converting the bytes back to string, so test it out
String realMessage = new String(messageByteArray, x, messageByteArray.length-x);
Вот что вы должны добавить в свой AndroidManifest.xml:
<receiver android:name=".SMSReceiver">
<intent-filter>
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
<data android:scheme="sms" />
<data android:host="localhost" />
<data android:port="12345" /><!-- this number should be the same as the `myApplicationPort` from above!!! -->
</intent-filter>
</receiver>