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
Dim ac As AnswerCall
Dim phid As PhoneId
End Sub
Sub Service_Create
pe.InitializeWithPhoneState("pe", phid)
ac.Initialize("answercall")
End Sub
Sub pe_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
If IncomingNumber = "09797666203" Then
KillCall
Else
ToastMessageShow(IncomingNumber, True)
ac.LetPhoneRing(3000)
If ac.isRinging == True Then
ac.AnswerPhone
End If
ac.enableSpeakerphone
End If
End Sub
Sub KillCall
' For This ---- You should add "AddPermission("android.permission.CALL_PHONE")" in manifest editor
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")
End Sub