Android Question PhoneEvents PhoneStateChanged IncomingNumber is empty

NeoTechni

Well-Known Member
Licensed User
Longtime User
B4X:
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
    If State = "RINGING" Then
        Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber)
    End If
End Sub

I have the permissions and service set up, so PE_PhoneStateChanged does get called. But the IncomingNumber is missing

Log result:
PhoneStateChanged, State = RINGING, IncomingNumber =

How do I get the number?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
I also needed this. I'd delete the thread but I no longer know how.

B4X:
rp.CheckAndRequest("android.permission.READ_CALL_LOG")
    wait for Activity_PermissionResult(permission As String, result As Boolean)
    Log("READ_CALL_LOG: " & result)
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Hi... that works for me...

B4X:
dim howrings as int =2  'must be 2 or 3... at low specs devices... i use 3... 2 rings is very fast...
dim ring as int = 0
dim ph as string

...

Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)

    ring=ring+1
    Log(ring)
    If ring<howrings Then
        Return
        Else
        ring=0
    End If
    Log("passing to check...")


    If State = "RINGING" Then
    ph=IncomingNumber.trim
    Log(ph)
    end if
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…