I\'ve been working on an app that sends SMS-messages. The problem I have is that the sendTextMessage method sends two messages with the same content. How do I fix that?
I've created a small Android library project that solves this issue using the reply from Stipa as well as code to make it work on HTC Tattoo and to make sure the right implementation is selected based on the device.
https://github.com/nadam/compatibility-sms-manager
This code will print out "SMS sent" when an activity returns, not when the sms is actually sent.
public void onReceive(Context context, Intent intent) {
switch (getResultCode()){
case Activity.RESULT_OK:
Log.i(TAG,"SMS sent");
break;
So what's probably happening is that another activity you have running is exiting and then returning RESULT_OK. I can't really tell though since I can see how you set up your broadcast receivers to receive.
Problem was the firmware as reported in the answers above.
There is an issue with firmware (LPQ) specifically for Galaxy S2 where SMS is sent twice on all 3rd party apps (including Handcent, GO SMS, etc) except stock messaging app. I think the latest version of firmware LP7 fixes the duplicate send SMS issue. Can you verify the firmware version on your phone?
Handcent & GO SMS has found their own workarounds and upgraded their apks to market.
Following code works fine, S2 with ICS:
void sendMessageGTI9100ICS(String number, String msg) throws Exception {
SmsManager m = SmsManager.getDefault();
Class aclass[] = new Class[9];
aclass[0] = String.class;
aclass[1] = String.class;
aclass[2] = ArrayList.class;
aclass[3] = ArrayList.class;
aclass[4] = ArrayList.class;
aclass[5] = Boolean.TYPE;
aclass[6] = Integer.TYPE;
aclass[7] = Integer.TYPE;
aclass[8] = Integer.TYPE;
Method method = m.getClass().getMethod("sendMultipartTextMessage", aclass);
Object aobj[] = new Object[9];
aobj[0] = number;
aobj[1] = null;
aobj[2] = m.divideMessage(msg);
aobj[3] = null;
aobj[4] = null;
aobj[5] = Boolean.valueOf(false);
aobj[6] = Integer.valueOf(0);
aobj[7] = Integer.valueOf(0);
aobj[8] = Integer.valueOf(0);
method.invoke(m, aobj);
}