B4A Library AnswerCall Library

Hello everyone,

SoyEli wanted to answer a call automatically in this topic, so I created this library.

It works together with Erel's PhoneEvents PhoneStateChanged.

Note that you should respect the order of events of the sample in phonestateChanged and that it will only work in a service.

Code:
Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
    Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber)
    Log(Intent.ExtrasToString)
   AC.LetPhoneRing(3000)
   If AC.isRinging == True Then
      AC.AnswerPhone
   End If
   AC.enableSpeakerphone
End Sub


It may not work on all devices (if you can test it out?)
It worked for my Xperia PLAY.

Attachements include the library files and a sample

Tomas
 

Attachments

Last edited:
This is great. Thanks :) Any chance you could add automatic hang-up and/or reject call to this library?
 
Jesus dude, you're catching up to Erel on the amount you've contributed to B4A
 
Thank you Tomas.
Can you add some codes to mute the phone automatically?
 
Looks good, can you give an example of picking up the phone,
then hanging it up, doesn't seem to hang up


Code:
   AC.LetPhoneRing(3000)
   
   If AC.isRinging == True Then
      AC.AnswerPhone
   End If
   AC.enableSpeakerphone
   
   ac.HookUpPhone()
 
Thank you Tomas.
Can you add some codes to mute the phone automatically?

You can mute the phone when ringing with this code:

Dim PE As PhoneEvents

Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent1 As Intent)
Dim P As Phone
If State = "RINGING" Then
P.SetRingerMode(P.RINGER_SILENT)
End If
End Sub
 
It didn't work on my HTC Sensation XE too. Hope Tomas will fix it soon :D
 
Doesn't work on my moto droid. I see a flash of the toast then the phone switches to normal mode where I swipe to answer.
 
I'm not having much luck getting .HookUpPhone to work either. Silencing the incoming call isn't sufficient for my needs. Apparently, .endcall has been removed from the ITelephony AIDL for Android 2.3 for security reasons. Does anyone have a workaround? i.e. is it possible to send "ATH" AT Command to the phone somehow?

Thanks

:sign0104:
 
didnt work for me (damn it!!) on an HTC Sensation (Z710a is the model if that matters)

Jeremy
 
AC.enableSpeakerphone

Wich is the use of .enableSpeakerpone in this library?:sign0085:
 
Back
Top