자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다.
- 제품설치/등록 오류 문의: 설치/등록 Q&A 이용 (제품 구매 고객 한정)
Delphi 전화통화 중인지... 확인
2017.05.31 11:38
안녕하세요.
델파이 10.2 트라리얼 버젼를 사용 중입니다.
안드로이드 스마트폰이 통화 중인지 아닌지.. 알려고 확인하려 합니다.
델파이 예제 중.. Phone Dialer 이 있는데..
이곳에.. 소스를 추가하여 통화중인지, 통화하는 중인지, 통화가 끝난건지.. 확인하려 하는데..
잘 안되는데.. 소스 확인 부탁드립니다.
unit uMain;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.PhoneDialer,
FMX.Platform, FMX.Edit, FMX.ListBox, FMX.Layouts, FMX.Controls.Presentation;
type
TPhoneDialerForm = class(TForm)
btnGetCarrierInfo: TButton;
btnMakeCall: TButton;
edtTelephoneNumber: TEdit;
lblTelephoneNumber: TLabel;
ToolBar1: TToolBar;
Label1: TLabel;
ListBox1: TListBox;
CarrierNameItem: TListBoxItem;
CountryCodeItem: TListBoxItem;
NetworkCodeItem: TListBoxItem;
MobileNetworkItem: TListBoxItem;
lblCallState: TLabel;
procedure btnGetCarrierInfoClick(Sender: TObject);
procedure btnMakeCallClick(Sender: TObject);
procedure MyOnCallStateChanged(const ACallID: String; const ACallState: TCallState);
private
{ Private declarations }
PhoneDialerService: IFMXPhoneDialerService;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
end;
var
PhoneDialerForm: TPhoneDialerForm;
implementation
{$R *.fmx}
constructor TPhoneDialerForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService));
if Assigned(PhoneDialerService) then
PhoneDialerService.OnCallStateChanged := MyOnCallStateChanged;
end;
procedure TPhoneDialerForm.MyOnCallStateChanged(const ACallID: String; const ACallState: TCallState);
var outText: String;
Begin
case ACallState of
TCallState.None: outText := 'No calls';
TCallState.Connected: outText := 'Connected';
TCallState.Incoming: outText := 'Incoming call';
TCallState.Dialing: outText := 'Dialing';
TCallState.Disconnected: outText := 'Disconnected';
end;
lblCallState.Text := outText;
End;
procedure TPhoneDialerForm.btnGetCarrierInfoClick(Sender: TObject);
{var
PhoneDialerService: IFMXPhoneDialerService;}
begin
{ test whether the PhoneDialer services are supported }
if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then
begin
{ if yes, then update the labels with the retrieved information }
CarrierNameItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetCarrierName;
CountryCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetIsoCountryCode;
NetworkCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileCountryCode;
MobileNetworkItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileNetwork;
end
else
ShowMessage('PhoneDialer service not supported');
end;
procedure TPhoneDialerForm.btnMakeCallClick(Sender: TObject);
var
PhoneDialerService: IFMXPhoneDialerService;
begin
{ test whether the PhoneDialer services are supported }
if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then
begin
{ if the Telephone Number is entered in the edit box then make the call, else
display an error message }
if edtTelephoneNumber.Text <> '' then
PhoneDialerService.Call(edtTelephoneNumber.Text)
else
begin
ShowMessage('Please type in a telephone number.');
edtTelephoneNumber.SetFocus;
end;
end
else
ShowMessage('PhoneDialer service not supported');
end;
end.
Delphi 전화통화 중인지... 확인
2017.05.31 11:38
안녕하세요.
델파이 10.2 트라리얼 버젼를 사용 중입니다.
안드로이드 스마트폰이 통화 중인지 아닌지.. 알려고 확인하려 합니다.
델파이 예제 중.. Phone Dialer 이 있는데..
이곳에.. 소스를 추가하여 통화중인지, 통화하는 중인지, 통화가 끝난건지.. 확인하려 하는데..
잘 안되는데.. 소스 확인 부탁드립니다.
unit uMain;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls, FMX.PhoneDialer,
FMX.Platform, FMX.Edit, FMX.ListBox, FMX.Layouts, FMX.Controls.Presentation;
type
TPhoneDialerForm = class(TForm)
btnGetCarrierInfo: TButton;
btnMakeCall: TButton;
edtTelephoneNumber: TEdit;
lblTelephoneNumber: TLabel;
ToolBar1: TToolBar;
Label1: TLabel;
ListBox1: TListBox;
CarrierNameItem: TListBoxItem;
CountryCodeItem: TListBoxItem;
NetworkCodeItem: TListBoxItem;
MobileNetworkItem: TListBoxItem;
lblCallState: TLabel;
procedure btnGetCarrierInfoClick(Sender: TObject);
procedure btnMakeCallClick(Sender: TObject);
procedure MyOnCallStateChanged(const ACallID: String; const ACallState: TCallState);
private
{ Private declarations }
PhoneDialerService: IFMXPhoneDialerService;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
end;
var
PhoneDialerForm: TPhoneDialerForm;
implementation
{$R *.fmx}
constructor TPhoneDialerForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService));
if Assigned(PhoneDialerService) then
PhoneDialerService.OnCallStateChanged := MyOnCallStateChanged;
end;
procedure TPhoneDialerForm.MyOnCallStateChanged(const ACallID: String; const ACallState: TCallState);
var outText: String;
Begin
case ACallState of
TCallState.None: outText := 'No calls';
TCallState.Connected: outText := 'Connected';
TCallState.Incoming: outText := 'Incoming call';
TCallState.Dialing: outText := 'Dialing';
TCallState.Disconnected: outText := 'Disconnected';
end;
lblCallState.Text := outText;
End;
procedure TPhoneDialerForm.btnGetCarrierInfoClick(Sender: TObject);
{var
PhoneDialerService: IFMXPhoneDialerService;}
begin
{ test whether the PhoneDialer services are supported }
if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then
begin
{ if yes, then update the labels with the retrieved information }
CarrierNameItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetCarrierName;
CountryCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetIsoCountryCode;
NetworkCodeItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileCountryCode;
MobileNetworkItem.ItemData.Detail := PhoneDialerService.GetCarrier.GetMobileNetwork;
end
else
ShowMessage('PhoneDialer service not supported');
end;
procedure TPhoneDialerForm.btnMakeCallClick(Sender: TObject);
var
PhoneDialerService: IFMXPhoneDialerService;
begin
{ test whether the PhoneDialer services are supported }
if TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, IInterface(PhoneDialerService)) then
begin
{ if the Telephone Number is entered in the edit box then make the call, else
display an error message }
if edtTelephoneNumber.Text <> '' then
PhoneDialerService.Call(edtTelephoneNumber.Text)
else
begin
ShowMessage('Please type in a telephone number.');
edtTelephoneNumber.SetFocus;
end;
end
else
ShowMessage('PhoneDialer service not supported');
end;
end.
모바일 튜토리얼로 전화걸기 상태를 추적하는 내용이 있으니 참고하시기 바랍니다.
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Mobile_Tutorial:_Using_the_Phone_Dialer_on_Mobile_Devices_(iOS_and_Android)