Question about PhoneSMS

kimble01

Member
Licensed User
Longtime User
Can PhoneSMS.Send be used in a background service?

When I run the small example, it runs fine being called from the activity. But it is throwing NullPointerException when called from the service...

Code:
B4X:
Log("Text received from "& From)
      Dim objSMS As PhoneSms
      Dim strTemp As String
      strTemp = "This phone is equipped with a ...
      Try
         If From.Length > 0 Then
            objSMS.Send(From, strTemp)
         End If
      Catch
         Log("Error Sending SMS was: " & LastException.Message)
      End Try

Appreciate all your help,
Gary

EDIT:
Found the Issue: The length of the text was over 160 Characters. That causes PhoneSMS to throw NullPointerException...
 
Last edited:
Top