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. 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.