B4A Library AnswerCall Library

XverhelstX

Well-Known Member
Licensed User
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.

B4X:
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:

Ronny

Member
Licensed User
This is great. Thanks :) Any chance you could add automatic hang-up and/or reject call to this library?
 

susu

Well-Known Member
Licensed User
Thank you Tomas.
Can you add some codes to mute the phone automatically?
 

vb1992

Well-Known Member
Licensed User
Looks good, can you give an example of picking up the phone,
then hanging it up, doesn't seem to hang up


B4X:
   AC.LetPhoneRing(3000)
   
   If AC.isRinging == True Then
      AC.AnswerPhone
   End If
   AC.enableSpeakerphone
   
   ac.HookUpPhone()
 

Ronny

Member
Licensed User
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
 

susu

Well-Known Member
Licensed User
It didn't work on my HTC Sensation XE too. Hope Tomas will fix it soon :D
 

Brad

Active Member
Licensed User
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.
 

thedansteruk

New Member
Licensed User
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:
 
Top