U
unba1300
Guest
Is there a way to detect an incoming phone call? I need to stop text-to-speech within my app if the phone rings. Thanks.
Dim PE As PhoneEvents
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
Select State
'Case "IDLE" ' Idle state.
Case "RINGING" ' Ringing state.
'your code ...
If FirstTime Then
StartService(sPhone)
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim PE As PhoneEvents
End Sub
Sub Service_Create
PE.Initialize("PE")
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_Destroy
End Sub
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber)
Msgbox("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber, "")
' Log(Intent.ExtrasToString)
End Sub
This is a small trick that was used before the manifest editor was available. By creating a PhoneId object you are forcing the compiler to add the android.permission.READ_PHONE_STATE permission. This permission is required in order to intercept incoming connections. However I didn't want to add this permission to PhoneEvents as the other events do not require it. So only if you need the phone state events then the permission is added.to be honest .. don't understand requirement of PhoneID ?
Service.StartForeground(1,sNotif)