I'm having a problem with PhoneEvents in that I can't get PhoneStateChanged and SMSDelivered to fire. The only event which fires is SmsSentStatus. I've tried everything I could think of to get the first two to fire. My understanding is that PhoneStateChanged should trigger as needed depending on what's going on with the phone and SMSDelivered when the recipient actually receives the message.
Out of those two, the second one is the one I actually care about. I put in the PhoneStateChanged just to test if PhoneEvents was working.
The code looks something like this. It's in a service module.
Help would be appreciated.
Out of those two, the second one is the one I actually care about. I put in the PhoneStateChanged just to test if PhoneEvents was working.
The code looks something like this. It's in a service module.
Help would be appreciated.
B4X:
Sub Process_Globals
...
Dim PE As PhoneEvents
Dim PhoneId As PhoneId
...
End Sub
Sub Service_Create
...
PE.InitializeWithPhoneState("PhEvents", PhoneId)[/INDENT]
End Sub
Sub <ForDemonstrationOnly>
...
Dim Ph As PhoneSms
Ph.Send2(strCellNumber,strMessage,True,True)
...
End Sub
Sub PhEvents_SmsSentStatus(Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent)
'LogStatus("----Send")
If(Success) Then
LogStatus("SMS Sent successfully")[/INDENT]
Else
LogStatus("SMS Send error. Phone # '" & PhoneNumber & "', Error message: '" & ErrorMessage & "'")
ProcessSMSResponse(PhoneNumber,ErrorMessage,True)[/INDENT]
End If
End Sub
Sub PhEvents_SmsDelivered (PhoneNumber As String, Intent As Intent)
LogStatus("----Delivered")
LogStatus("SMS delivered to Phone # '" & PhoneNumber & "'")
CallSub2(Main,"AddProgress","SMS delivered to Phone # '" & PhoneNumber & "'")
End Sub
Sub PhEvents_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
LogStatus("PhoneStateChanged to '" & State & "'")
CallSub2(Main,"AddProgress","PhoneStateChanged to '" & State & "'")[/INDENT]
End Sub
Last edited: