I am using the following code in the Starter Service, but the PhoneStateChanged event does not trigger:
I am running Android 5.1
I have added the following line to the Manifest:
B4X:
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
LogColor("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber, Colors.Magenta)
LogColor(Intent.ExtrasToString, Colors.Magenta)
KillCall
End Sub
Sub KillCall
Dim r As Reflector
r.Target = r.GetContext
Dim TelephonyManager, TelephonyInterface As Object
TelephonyManager = r.RunMethod2("getSystemService", "phone", "java.lang.String")
r.Target = TelephonyManager
TelephonyInterface = r.RunMethod("getITelephony")
r.Target = TelephonyInterface
r.RunMethod("endCall")
LogColor("Call Killed", Colors.Magenta)
End Sub
I have added the following line to the Manifest:
B4X:
AddPermission("android.permission.CALL_PHONE")