#Region Service Attributes
#StartAtBoot: True
#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 sq1 As SQL
Dim c1 As Cursor
Dim mysq_fo As String : mysq_fo = File.DirRootExternal & "/Android/AungLay_black"
' ////////////////////
' Dim names, nums As String
' Dim texR As TextReader
Dim numbers() As String
' --------------------
Dim pe As PhoneEvents
Dim pid As PhoneId
Dim ac As AnswerCall
End Sub
Sub Service_Create
If File.Exists(mysq_fo, "") = False Then
File.MakeDir(File.DirRootExternal, "/Android/AungLay_black")
End If
' ---------------------
If File.Exists(mysq_fo, "Black_db.db") = False Then
File.Copy(File.DirAssets, "Black_db.db", mysq_fo, "Black_db.db")
End If
' --------------------
If sq1.IsInitialized = False Then
sq1.Initialize(mysq_fo, "Black_db.db", True)
End If
' -----------------------------
pe.InitializeWithPhoneState("pe", pid)
ac.Initialize("ac")
End Sub
Sub Service_Start (StartingIntent As Intent)
ToastMessageShow("Now Start Service!!!", True)
End Sub
Sub Service_Destroy
End Sub
Sub pe_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
' ------------------ Whit DB
c1 = sq1.ExecQuery("SELECT Number FROM Black_table")
For i = 0 To c1.RowCount - 1
c1.Position = i
numbers = Array As String(c1.GetString("Number"))
If numbers(i).Contains(IncomingNumber) Then
Kill_Call
' ToastMessageShow(IncomingNumber, True)
' ac.LetPhoneRing(3000)
' If ac.isRinging == True Then
' ac.AnswerPhone
' End If
' ac.enableSpeakerphone
Else
' Kill_Call
ToastMessageShow(IncomingNumber, True)
ac.LetPhoneRing(3000)
If ac.isRinging == True Then
ac.AnswerPhone
End If
ac.enableSpeakerphone
End If
Next
End Sub
Sub Kill_Call
' 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