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.

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

  • AnswerCall.zip
    9.5 KB · Views: 1,412
  • AnswerCall1.1.zip
    9.7 KB · Views: 1,956
Last edited:

Ronny

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

NeoTechni

Well-Known Member
Licensed User
Longtime User
Jesus dude, you're catching up to Erel on the amount you've contributed to B4A
 

susu

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

vb1992

Well-Known Member
Licensed User
Longtime 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
Longtime 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
Longtime User
It didn't work on my HTC Sensation XE too. Hope Tomas will fix it soon :D
 

Brad

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

jscoulter

Member
Licensed User
Longtime User
didnt work for me (damn it!!) on an HTC Sensation (Z710a is the model if that matters)

Jeremy
 

jzamora

New Member
Licensed User
Longtime User
AC.enableSpeakerphone

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