Android Question SendLargeSms

sirjo66

Well-Known Member
Licensed User
Longtime User
I use this code for to send SMS (code by Erel):
http://www.b4x.com/android/forum/threads/max-length-of-sms-message.20006/#post-115689

and it works very well until the message is over 160 characters.

If I send a short message it works, if I send a large message it works on first SMS,
then it don't works on other large SMS.
After the first large SMS, it don't send large SMS, but only short SMS.

Example:
1) send SMS: hello
2) send SMS: hello world with many many chars (more than 160)
3) send SMS: hello again
4) send SMS: hello world for the second time with many many chars (more than 160)
5) send SMS: hello my friends
6) send SMS: hello to all
7) send SMS: hello world for the 3th time with many many chars (more than 160)
8) send SMS: good night

On my phone I receive SMS number 1, 2, 3, 5, 6 and 8

After the first large SMS don't works large SMS but only short SMS

Why ???

Sergio
 

Humberto

Active Member
Licensed User
Longtime User
Derek

The function works in other phones like Samsung S3 ( regular ) , LG I, Moto X Play ( with android 5.1 )

Why just in Samsung S3 mini ?
Do you know a workaround ?
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
sirjo66
I have the same problem with Samsung S3 mini large sms is not sending.
I have a LG I with the andorid 4.1.2 and works
The problem seems to be the Samsung S3 mini.
Could you find I way to send large SMS with it?

Hi Humberto,
I don't solve the problem, it works on ALL device eccept Samsung S3 mini (GT-I8190) and I don't know why :(

Sergio
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi

I dont know if this will help, we have an app that sends large SMS messages. We divide the size of the large message by 160 (max size of a normal sms) and multiple the result (rounded up) by 7. The 7 is the number of seconds that it takes for a traditional SMS to be sent. So after you send the Large SMS wait for that number of seconds before you send any other type of SMS mesage.

Regards

John.
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
I'm sorry Jmu but I don't understand what you mean :(
If you divide a large SMS into small SMS and send it (with a delay of 7 seconds after each SMS), who receive these SMS see many SMS or only a SMS ??
I need only one SMS on the receiver device, no more of one.

The routine works very well on ALL device, only on S3 mini there is this problem, so my customer don't have S3 mini model.

Sergio
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
I'm sorry Jmu but I don't understand what you mean :(
If you divide a large SMS into small SMS and send it (with a delay of 7 seconds after each SMS), who receive these SMS see many SMS or only a SMS ??
I need only one SMS on the receiver device, no more of one.

The routine works very well on ALL device, only on S3 mini there is this problem, so my customer don't have S3 mini model.

Sergio

Hi Sergio,

No. the calculation lets you know how long to wait for after you send the large SMS. Here's the code :)

B4X:
Sub SendLargeSms(Destination As String, Message As String)

     Dim r As Reflector, t As Long, ts As Int
     
     mod_functions.writelog("svc_sms(),SendLargeSms")
     Main.CALLSTATE.sms_busy = True
     Try
       ' // calc the part
     ts = Round(Message.Length / 160)
     ts = ts * 7 ' parts * seconds = totals seconds to wait, 7 represents 1 short message send in seconds

     r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
     
       Dim parts As Object
       parts = r.RunMethod2("divideMessage", Message, "java.lang.String")
       r.RunMethod4("sendMultipartTextMessage", _
               Array As Object(Destination, Null, parts, Null, Null), _
               Array As String("java.lang.String", "java.lang.String", _
             "java.util.ArrayList", "java.util.ArrayList", "java.util.ArrayList"))
     
     ' // calc seconds to wait
     t = DateTime.Add(DateTime.Now + (DateTime.TicksPerSecond  * ts),0,0,0)

     mod_functions.writelog("svc_sms(), Sending Long SMS to " & Destination  & ", " & DateTime.Time(t))
     
     ' // wait here for device to send large SMS
     Do While t > DateTime.Now
       DoEvents
     Loop

     ' // remove the message if it is the outbox - this can occur on some phones
     mod_functions.manage_sms(s.mobile_number,s.message_1,sm.TYPE_OUTBOX,1)
     If paused Then
       Main.CALLSTATE.sms_paused = True
     End If
   Catch
     mod_functions.logError("svc_sms(),SendLargeSms, " & LastException.Message )
   End Try

   Main.CALLSTATE.sms_busy = False

End Sub

You can ignore any of the mod_functions call's as there are only relevant to my app, also any references to Main.??? are also specific to my app.

Hope the helps you over come your problems.

Regards

John.
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
I send a large SMS, wait 1 minute and then send another large SMS, it don't work :(
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
I would suggest that you look at the unfiltered logs, also, when the second messages fails, exit your app and see if it sends then.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Also, if you are using a service to send the messages, maybe try to exit the service after the first message is sent and you have delayed for the 1 minute, then start the service to send the second message.
 
Upvote 0

Humberto

Active Member
Licensed User
Longtime User
The problem with S3 Mini is that no message is sent.
Even the first one and it just happens with this specific phone.
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
I think that the problem may be to do with a message number field embedded in the header. Where you are sending multiple messages to the same recipient this field needs to be different for each message. There are some other threads related to this issue.

Hello Derek,
I try to send a large SMS to a phone, then wait 1 minute, and send another large SMS to another phone, but it don't work
 
Upvote 0
Top