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
 

sirjo66

Well-Known Member
Licensed User
Longtime User
Thank for your reply.

If I try with a Samsung Note N7000, it works very well, I can send large SMS as I want, but if I try with a Samsung S III mini (GT-I8190N) it don't works :(

I have change Sub in this mode (only insert Log commands):
B4X:
Sub SendLargeSms(Destination As String, Message As String)

   Log(">>> Start SendLargeSms Sub...")
  Dim r As Reflector
  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"))
   Log(">>> End SendLargeSms Sub...")
   
End Sub

I reset my phone, connect it to B4A, unfilter logs and I send a large SMS, this is what I see in logs:
B4X:
>>> Start SendLargeSms Sub...

GC_CONCURRENT freed 205K, 14% free 10103K/11719K, paused 13ms+14ms, total 56ms
SmsRestrictionPolicy.canOutgoingSms >>>>
SmsRestrictionPolicy.canOutgoingSms >>>>
sendSms:  mRetryCount=0 mMessageRef=0 SS=0
SmsRestrictionPolicy.canOutgoingSms >>>>
CatService: handleMsg : MSG_ID_CALL_CONTROL_RESULT
CatService: Call control result data01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000
CatService: The call control result by SIM = 0
CatService: The call control result by SIM : alphaidpresent = false
SmsRestrictionPolicy.canOutgoingSms >>>>
sendSms:  mRetryCount=0 mMessageRef=0 SS=0
SmsRestrictionPolicy.canOutgoingSms >>>>
SmsRestrictionPolicy.canOutgoingSms >>>>
sendSms:  mRetryCount=0 mMessageRef=0 SS=0

>>> End SendLargeSms Sub...

refreshSignalCluster: data=-1 bt=false
CatService: handleMsg : MSG_ID_SEND_SMS_RESULT
CatService: handleMsg : MSG_ID_CALL_CONTROL_RESULT
CatService: Call control result data01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000
CatService: The call control result by SIM = 0
CatService: The call control result by SIM : alphaidpresent = false

refreshSignalCluster: data=-1 bt=false
update start
level:68 scale:100 status:2 health:2 present:true voltage: 4030 temperature: 328 technology: Li-ion AC powered:false USB powered:true icon:17303270 invalid charger:0 online:4 charge type:0 current avg:195
onReceive() - ACTION_BATTERY_CHANGED
onReceive() - level:68
onReceive() - plugged:2
In MTPAPP onReceive:android.intent.action.BATTERY_CHANGED
battPlugged Type : 2
onReceive() - BATTERY_STATUS_CHARGING:
ACTION_BATTERY_CHANGED
NORMAL_BATTERY
CatService: handleMsg : MSG_ID_SEND_SMS_RESULT
CatService: handleMsg : MSG_ID_CALL_CONTROL_RESULT
CatService: Call control result data01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000
CatService: The call control result by SIM = 0
CatService: The call control result by SIM : alphaidpresent = false
refreshSignalCluster: data=-1 bt=false
CatService: handleMsg : MSG_ID_SEND_SMS_RESULT
!@Sync 5
update start
level:68 scale:100 status:2 health:2 present:true voltage: 4057 temperature: 329 technology: Li-ion AC powered:false USB powered:true icon:17303270 invalid charger:0 online:4 charge type:0 current avg:195
onReceive() - ACTION_BATTERY_CHANGED
onReceive() - level:68
onReceive() - plugged:2
onReceive() - BATTERY_STATUS_CHARGING:
In MTPAPP onReceive:android.intent.action.BATTERY_CHANGED
battPlugged Type : 2
ACTION_BATTERY_CHANGED

.... I see that from >>> Start SendLargeSms Sub... to >>> End SendLargeSms Sub... there are many lines.

On destination phone I can see that the SMS is arrived !!

Wait some seconds, and try to send the same SMS, but now the SMS don't arrive and into logs I see:
B4X:
>>> Start SendLargeSms Sub...

>>> End SendLargeSms Sub...

update start
level:69 scale:100 status:2 health:2 present:true voltage: 4052 temperature: 328 technology: Li-ion AC powered:false USB powered:true icon:17303270 invalid charger:0 online:4 charge type:0 current avg:244
In MTPAPP onReceive:android.intent.action.BATTERY_CHANGED
battPlugged Type : 2
onReceive() - ACTION_BATTERY_CHANGED
onReceive() - level:69
onReceive() - plugged:2
onReceive() - BATTERY_STATUS_CHARGING:
ACTION_BATTERY_CHANGED
NORMAL_BATTERY
refreshSignalCluster: data=-1 bt=false
refreshSignalCluster: data=-1 bt=false
handleTimeout
waitForAlarm result :4
update start
level:69 scale:100 status:2 health:2 present:true voltage: 4062 temperature: 328 technology: Li-ion AC powered:false USB powered:true icon:17303270 invalid charger:0 online:4 charge type:0 current avg:211
onReceive() - ACTION_BATTERY_CHANGED
onReceive() - level:69
onReceive() - plugged:2
onReceive() - BATTERY_STATUS_CHARGING:
ACTION_BATTERY_CHANGED

NORMAL_BATTERY
In MTPAPP onReceive:android.intent.action.BATTERY_CHANGED
battPlugged Type : 2
waitForAlarm result :8

ClockReceiver onReceive() ACTION_TIME_TICK
FACTORY_ON= 0
onReceive() - ACTION_TIME_TICK
onReceive() - ACTION_TIME_TICK
update start
level:69 scale:100 status:2 health:2 present:true voltage: 4065 temperature: 328 technology: Li-ion AC powered:false USB powered:true icon:17303270 invalid charger:0 online:4 charge type:0 current avg:211

..... no lines between >>> Start SendLargeSms Sub... and >>> End SendLargeSms Sub... :(

Sergio
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
sirjo66: I would suggest you to use PhoneSms library to send message with less than 160 characters. ONLY for those that longer than 160 then you can use that SendLargeSms method. With this workaround you will not have any problem. I am using same tactics in my app. Hope this works for you too. Sometimes life is simpler than we, the programmers, think about it... :)
 
Last edited:
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
Hello bsnqt and thanks for your message

I have already try it but don't works :(

Sergio
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Hi sirjo66: what do you mean "don't works"? both of them should work separately. Can you let us know what error you receive now separately from these 2 methods? Logically, if it does not work with SendLargeSms, I don't think the error should come from sending messages with less than 160 chrs. (as you described in your very first post), as now they are handled separately...

Btw, what is Android that your Samsung S III mini (GT-I8190N) is running?
 
Last edited:
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
Hi bsnqt !

I have separate two Sub, one is txt.lenght <= 160 and the other is txt.lenght >160 chars

For txt.lenght <= 160 it works on every SMS, no problem, but the routine with txt.lenght >160 works only on the first call, the SMS is received correctly, but from the second call the routine don't works, there isn't any error, but the SMS don't arrive.
If I want to send another SMS with txt.lenght >160 I need to restart the phone

May be a SO problem (like Erel has write to me), because I have try it on three different phones with different SO and:
on Samsung GT-I5800 with SO 2.2 it works
on Samsung GT-I8190 with SO 4.1.2 don't works
on Samsung N7000 with SO 4.0.4 it works

I think it is a SO bug, but it is very strange

Sergio
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Let me try your code with my Galaxy Note II (GT-N7100) which is running also on 4.1.2 and let you know the result.
Can you post the code of the Sub that send large message, please use exactly as they are in your project, don't change anything.
If cannot post then you can PM me.
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
Here is:

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

  Dim r As Reflector
  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"))
     
End Sub
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
Hi sirjo66: I have "stress" tested the code above, I can confirm with you that it works very well. I did send 10 sms during a minute without any problem on my Galaxy note II (which is running on 4.1.2 too). All sms arrived and I can received them in order.

I have not created any special code, just added a button to send the sample sms using the method you posted. Attached is the project, just in case.

Another possible reason is the receiver on tested device. Have you installed any call & sms blocking softwares in your tested device, especially the one with error in receiving the message (the receiver device that don't receive message)?
 

Attachments

  • SendLargeSms.zip
    7.4 KB · Views: 378
Last edited:
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
Many thanks for the example, but as my program it send the first SMS and then don't works :(

No blocking software installed on my tested device.

Sergio
 
Upvote 0

Humberto

Active 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?
 
Upvote 0

Derek Johnson

Active 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.
 
Upvote 0
Top