Android Question problem with Sub SendLargeSms

Masoud44

Member
Hi
I need send large sms and for this i try to use from Sub SendLargeSms but when send more than 160 character my app stops
I'm Add this line to the manifest editor
AddPermission(android.permission.SEND_SMS)
what is the problem?
 

JohnC

Expert
Licensed User
Longtime User
When you app "stops", it will most likely display a bunch of lines on the "logs" tab in the IDE.

Please use the <code></code> tags to post those lines in this thread so we can get an idea of the actual error being thrown.
 
Upvote 1

Masoud44

Member
test large sms:
#Region  Project Attributes
    #ApplicationLabel: sms test
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals

End Sub

Sub Globals
    Private Bsendlarg As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

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")
    Log(parts)
    Log(Destination)
    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

Private Sub Bsendlarg_Click
    Dim message As String
    Dim number As String
    
    number="+989371111111"
    message="1234567890 1234567890 "
    message=message&CRLF&message&CRLF&message&CRLF&message&CRLF&message&CRLF&message&CRLF&message&CRLF&"1234567"

    Log(message.Length) 'when less than 160 it is work but when more than 160 it is stops(app crashes)
    SendLargeSms(number,message)
End Sub
When you app "stops", it will most likely display a bunch of lines on the "logs" tab in the IDE.

Please use the <code></code> tags to post those lines in this thread so we can get an idea of the actual error being thrown.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Thank you for posting the project code.

But please also post the error message lines from the "Logs" tab inside the IDE - When your app crashes, there should be error message lines in the list of events on the "Logs" tab inside the IDE.
 
Last edited:
Upvote 0

Masoud44

Member
It doesn't give any error message on the simulator, and it gives an error and stops on the mobile phone (unfortunately, sms test has stopped)
 
Upvote 0

Masoud44

Member
There must be an error message in the logs when the process crashes.
Of course, an error is given on my main program in the log section, but there is no error in this test program
 

Attachments

  • javaerror.png
    javaerror.png
    225.5 KB · Views: 26
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Thank you for including the screenshot - those red lines are what we were looking for because they show the error details that android is reporting.

The error displayed is saying that your app requires you to add both the permission of "READ_PHONE_STATE" to your app's manifest and as a runtime permission request and have the user approve that permission.
 
Last edited:
Upvote 0

Masoud44

Member
Thanks for your help Erel and johncšŸ„°
By adding these two permissions to the manifest, the problem was solved
AddPermission(android.permission.SEND_SMS)
AddPermission("android.permission.READ_PHONE_STATE")
 
Upvote 0
Top