' in a toggle button event as part of Main
Sub btnDND_CheckedChange(Checked As Boolean)
If Checked Then
StartService(svc_dnd)
Else
StopService(svc_dnd)
End If
End Sub
'Service module: svc_dnd
Sub Process_Globals
Dim PhoneId As PhoneId
Dim PE As PhoneEvents
Dim p As Phone
Dim sNotif As Notification
End Sub
Sub Service_Create
PE.InitializeWithPhoneState("PE", PhoneId)
p.SetMute(p.VOLUME_RING,True)
sNotif.Initialize
sNotif.Icon = "icon"
sNotif.SetInfo("DND","Service Running",Main)
sNotif.Sound = False
sNotif.Vibrate = False
sNotif.Notify(1)
Service.StartForeground(1,sNotif) 'ok notification fires
End Sub
Sub Service_Start(StartingIntent As Intent)
Log("start: "&StartingIntent) 'ok this one fires
End Sub
Sub Service_Destroy
PE.StopListening 'used when I call StopService from main
End Sub
Sub PE_PhoneStatusChanged(State As String, IncomingNumber As String, Intent As Intent)
Log("status: "&State) 'NO. it never fires!!
Log("number: "&IncomingNumber)
Log("intent: "&Intent)
If State ="RINGING" Then
Log("ringing") 'NO. never fires
p.SetMute(p.VOLUME_RING,False)
End If
End Sub