Android Question how do I automatically send an MMS?

RichyK68

Active Member
Licensed User
Longtime User
Hi,

I'm trying to send an MMS (just a picture) automatically from a driving app I've written. I already send text messages with this code:

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

I found this code which I thought was for sending an image (Data() contains the byte image returned by the Camera class).

B4X:
    Try
        Dim sm As JavaObject
        sm = sm.InitializeStatic("android.telephony.SmsManager").RunMethod("getDefault", Null)
        Dim port As Short = 90
        sm.RunMethod("sendDataMessage", Array(NumberToMessage, "", port, Data, Null, Null))
    Catch
        Log(LastException.Message)
    End Try

But it doesn't work so it's obviously not what it was intended for. How can I send an image automatically through SMS/MMS without any further user intervention?

Thanks,

Richard
 

DonManfred

Expert
Licensed User
Longtime User
i found this in the related threads above your post...
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
Thanks. I believe, but haven't actually tried, that it starts an activity to send the MMS whereas I just want the MMS to be sent to the specified number automatically (as text messages are). I'm currently looking at the MMS library for Basic4Android.
 
Upvote 0
Top