Android Question killcall no longer works. can anybody help?

mhk1368

Member
hi
I tried to reject the call with the following program in Android 11, but it does not work and gives the following error.( r.RunMethod("endCall"))
java.lang.NoSuchMethodException: java.lang.Object.endCall []
I just need a piece of code that can reject the call.

example:
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent1 As Intent)
        
    If State="RINGING" Then
        'Squillo
        if IncomingNumber ="0039333xxxx" then KillCall   
    Else If State="OFFHOOK" Then
        ' OFF Hook
    else If State="IDLE" Then
        'IDEL
        
    End If
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")
End Sub
 

Magma

Expert
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

bentsvendsen

New Member
Licensed User
Longtime User
I have an old app where I used the endCall method to block incoming calls. I am trying to use the callScreeningService, and I got the roleManager part working.

I have this part in the manifest and my service is started when I receive an incoming Call:

AddApplicationText(
<service
android:name="b4a.bes.rolemanager.myservice"
android:permission="android.permission.BIND_SCREENING_SERVICE">
<intent-filter>
<action android:name="android.telecom.CallScreeningService"/>
</intent-filter>
</service>
)



But I struggle with this next part. I hope someone in this forum can help.


CallScreeningService Lifecycle​

The framework binds to the CallScreeningService implemented by the user-chosen app filling the RoleManager.ROLE_CALL_SCREENING role when incoming calls are received (prior to ringing) and when outgoing calls are placed. The platform calls the onScreenCall(android.telecom.Call.Details) method to provide your service with details about the call.
For incoming calls, the CallScreeningService must call respondToCall(android.telecom.Call.Details, android.telecom.CallScreeningService.CallResponse) within 5 seconds of being bound to indicate to the platform whether the call should be blocked or not.
 
Upvote 0
Top