If I use the following code - which I found in the forum - for sending an sms, the IDE moans that 'ps is never assigned any value'. However, if I comment the 'Dim ps as PhoneSms' out, sending an sms fails.
Why is that? Which value should be assigned to ps to prevent the IDE from complaining?
Here's the code I found (unfortunately I messed up the formatting a little bit, sorry for that):
Thanks and best regards
Why is that? Which value should be assigned to ps to prevent the IDE from complaining?
Here's the code I found (unfortunately I messed up the formatting a little bit, sorry for that):
B4X:
Sub SendSms(PhoneNumber AsString, Text AsString)
' if smssendallow = true then 'give the option to deny sms text sending in the settings.
Try
Dim ps As PhoneSms '-> Sending sms doesn't work if this is commented out
Dim r As Reflector
r.Target = r.RunStaticMethod("android.telephony.SmsManager", "getDefault", Null, Null)
r.RunMethod4("sendTextMessage", ArrayAs Object(PhoneNumber, Null, Text, Null, Null), _
ArrayAsString("java.lang.String", "java.lang.String", "java.lang.String", _
"android.app.PendingIntent", "android.app.PendingIntent"))
ToastMessageShow("Sent SMS Text to " & PhoneNumber, False)
Catch
Log("Failed to send SMS to " & PhoneNumber)
End Try
End Sub
Thanks and best regards