End Call Incoming

koaunglay

Member
Licensed User
Longtime User
If so b4a can't write blacklists apk
Sorry I really don't know.
Not sure that I understand the question. I'm also not familiar with the AnswerCall library which most probably doesn't work on all devices.
 

Totty

New Member
Licensed User
Longtime User
B4X:
        For i = 0 To Main.c.RowCount - 1
            Main.c.Position = i
            Main.c.GetString("ph_num")
                            If Main.c.GetString("ph_num").Contains(IncomingNumber) Then    '     "09797666203" Then    /    IncomingNumber =
                                KillCall
                            Else
                                ToastMessageShow(IncomingNumber, True)
                                ac.LetPhoneRing(3000)
                                    If ac.isRinging == True Then
                                        ac.AnswerPhone
                                    End If
                                    ac.enableSpeakerphone
                            End If     
        Next

My first post, and I know this is an old thread, but I was looking at something similar for a first project, as I'm getting inundated with cold calls. The issue here is that the "If" structure is inside the loop, so ANY whitelisted number before the blacklisted number will allow the phone to ring for 3 seconds. You need a boolean (e.g. no_is_blacklisted) set at the start to false, then run through the loop and set it to True if/when you hit a blacklisted number.

Then your code is something like:
B4X:
no_is_blacklisted = False
For i=0 to Main.c.RowCount -1
  Main.c.Position = i
  If Main.c.GetString("ph_num").Contains(IncomingNumber) Then
    no_is_blacklisted = True
  End If
Next
If no_is_blacklisted == True
  KillCall
Else
  <show/ring/handle speakerphone>
End If

Oh, and your blacklist should miss out the first "0", e.g. 7979666203, so that "+44797966203" is handled too.
 
Last edited:
Top