Jump to content
erdoganozkaya

Receiving incoming calls

Recommended Posts

Hello friends,

 

How do I get Android incoming calls instantly?

 

IFMXPhoneDialerService, I would be glad if you share an example.

 

Thank you.

 

 

Share this post


Link to post
15 hours ago, erdoganozkaya said:

I want to receive incoming calls

Then do what Dave said to do:

18 hours ago, Dave Nottage said:

Just create a handler for the OnCallStateChanged event of FPhoneDialerService, handle TCallState.Incoming and fetch the call using GetCurrentCalls

In other words, add something like this to the code:

procedure TPhoneDialerForm.FormCreate(Sender: TObject);
begin
{$IFDEF ANDROID}
  FCallPhonePermission := JStringToString(TJManifest_permission.JavaClass.CALL_PHONE);
{$ENDIF}
  { test whether the PhoneDialer services are supported }
  if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, FPhoneDialerService) then
    FPhoneDialerService.OnCallStateChanged := CallStateChanged; // <-- ADD THIS!
end;

procedure TPhoneDialerForm.CallStateChanged(const ACallID: String; const AState: TCallState);
var
  Calls: TCalls;
  Call: TCall;
begin
  if AState = TCallState.Incoming then
  begin
    Calls := FPhoneDialerService.GetCurrentCalls;
    try
      for Call in Calls do
      begin
        if Call.GetCallID = ACallID then
        begin
          // use Call as needed ...
          Exit;
        end;
      end;
    finally
      for Call in Calls do
        Call.Free;
    end;
  end;
end;

 

Edited by Remy Lebeau

Share this post


Link to post
On 2/16/2020 at 6:15 AM, erdoganozkaya said:

Thank you for your answer, could you please make a small example?

Was there something wrong with the example I gave you in my previous reply?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×