Android Question sendTextMessage works in one app but not another

RichyK68

Active Member
Licensed User
Longtime User
Hi,

I wrote an app called Backseat Buddy which is used during driving and I've been using it for bloody ages, and one of the things it does is to reply to incoming messages while I'm driving. Recently I noticed it had stopped working. My first thought was that in another app of mine called Turn Me On, in which I recently implemented an auto reply facility, was receiving the messages instead but BB was reading out the messages so this meant BB should be replying to them. Anyway, I've gone into the debugger and done some tests and BB is definitely running the code that sends the replies. The number and message are both correct. Here is the code.

B4X:
Sub SendSMS(number As String, Message As String)

    Try
        Dim r As Reflector
        r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
        r.RunMethod4("sendTextMessage", Array As Object(number, Null, Message, Null, Null), _
         Array As String("java.lang.String", "java.lang.String", "java.lang.String", _
           "android.app.PendingIntent", "android.app.PendingIntent"))    'Dim i As Intent
    Catch
        Log(LastException.Message)
    End Try

End Sub

This code has been in there for a very long time and working fine. It is still going through the motions but no messages are being sent. The autoreply code in TMO is ripped off from BB and does actually work. I can tell TMO to reply to incoming messages and it does so perfectly, and BB even reads them out! BB goes through the motions of sending the messages but nothing arrives back to me or is even logged in the Messages app.

My permissions are correct with

B4X:
<uses-permission android:name="android.permission.SEND_SMS"/> 
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.RECIEVE_SMS"/>

so I'm at a loss as to why the exact same code in one app runs perfectly, but it is executed but ignored in the other app.

Any ideas?

Richard
 

RichyK68

Active Member
Licensed User
Longtime User
Both apps are running on my LG G2, so the same version of Android. I tried the PhoneSMS object this morning and that executes the command to send the message but no message is sent. It's very weird how it has suddenly stopped working.
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
I took a punt and completely uninstalled and then reinstalled BB, and it's all working again. Very strange, especially given that I stepped through it with the debugger to confirm that it was sending the message.
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
Interesting!!! I just checked both apps and they are both behaving as they should. If it fails again in the future, at least I'll know what I have to do, even though I shouldn't have to.

Thanks :)
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
My fault. Both BB and TMO have been told not to reply to the same number unless a set period of time has elapsed.
 
Upvote 0
Top