Android Question Auto Answer Call

Jaco vd Walt

Licensed User
I know that this has been discussed several times in the past, and up to now it seems like there was no solution. However according to the issue tracker from Google, since Android 8, this was resolved by means of using this code :

  if(Build.VERSION.SDK_INT >= 26) {
                if(checkSelfPermission("android.permission.ANSWER_PHONE_CALLS") == PackageManager.PERMISSION_GRANTED) {
                        TelecomManager tm = (TelecomManager) this.getSystemService(Context.TELECOM_SERVICE);
                        if(tm != null)
This is java code, and just before I test it using the javaobject method in b4a, I was wondering if there was a better way to do it in b4a ?

So to be clear, is there someone who could convert the code to b4a :)

Thanks !


Staff member
Licensed User
Add the permission with AddPermission(android.permission.ANSWER_PHONE_CALLS) in the manifest editor.

Request it at runtime with rp.CheckAndRequest("android.permission.ANSWER_PHONE_CALLS")
You will need to answer from the service. You can use rp.Check to check whether you have permission or not.

Dim ctxt As JavaObject
Dim tm As JavaObject = ctxt.RunMethod("getSystemService", Array("telecom"))
if tm.IsInitialized Then tm.RunMethod("acceptRingingCall", Null)