Jump to content
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr ×
과거의 기술자료(읽기 전용): https://tech.devgear.co.kr
  • 0

RAD STUDIO 11 업그레이드 후 안드로이드에서 전화걸기 에러발생


강명진

질문

6 answers to this question

Recommended Posts

  • 0
On 2021. 11. 12. at 오전 12시 58분, c2design said:

단순히 전화걸기만 했다고 하시면 어떻게 하셨는지 알수가 없습니다.

관련 소스도 같이 올려주셔야 답변해 드릴수 있습니다.

unit CustTelD;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
  FMX.Controls.Presentation, FMX.Layouts, FMX.Effects, FMX.Edit, FMX.ListBox,
  FMX.Objects, FMX.PhoneDialer, FMX.Platform, System.Permissions,
  FMX.Memo.Types, FMX.ScrollBox, FMX.Memo;

type
  TfmCustTelD = class(TForm)
    Layout1: TLayout;
    Panel3: TPanel;
    Timer: TTimer;
    ToolBar1: TToolBar;
    txTitle: TText;
    Panel6: TPanel;
    Line3: TLine;
    Panel7: TPanel;
    ShadowEffect4: TShadowEffect;
    Panel1: TPanel;
    ShadowEffect1: TShadowEffect;
    lbxSUnitPrice: TListBox;
    lbiS1: TListBoxItem;
    lbTDate: TLabel;
    Label7: TLabel;
    lbTTime: TLabel;
    Label11: TLabel;
    lbTClass: TLabel;
    lbiS2: TListBoxItem;
    lbCustName: TLabel;
    lbiS3: TListBoxItem;
    lbRepName: TLabel;
    lbiS4: TListBoxItem;
    lbPhone: TLabel;
    Label1: TLabel;
    lbMobile: TLabel;
    lbiS5: TListBoxItem;
    lbAddr: TLabel;
    ShadowEffect2: TShadowEffect;
    Layout3: TLayout;
    lbClock2: TLabel;
    lbClock1: TLabel;
    Layout4: TLayout;
    Button1: TButton;
    bbnInsert: TButton;
    bbnCancel: TButton;
    Panel2: TPanel;
    Line4: TLine;
    Layout5: TLayout;
    bbnSUnit: TButton;
    lbJobName: TLabel;
    bbnCancel2: TButton;
    bbnPhone: TButton;
    bbnMobile: TButton;
    Layout2: TLayout;
    txLocName: TText;
    Text1: TText;
    Splitter1: TSplitter;
    Line1: TLine;
    Panel12: TPanel;
    memComment2: TMemo;
    Panel11: TPanel;
    memComment1: TMemo;
    procedure TimerTimer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure bbnPhoneClick(Sender: TObject);
    procedure bbnMobileClick(Sender: TObject);
    procedure bbnInsertClick(Sender: TObject);
    procedure bbnCancelClick(Sender: TObject);
  private
    { Private declarations }
    FPhoneDialerService: IFMXPhoneDialerService;
    FCallPhonePermission: string;
    type
      TCustTel = Record
        CustTelNo : LongInt;
    end;
    var
      TTCustTel : TCustTel;
    procedure DisplayRationale(Sender: TObject;
      const APermissions: TClassicStringDynArray; const APostRationaleProc: TProc);
    procedure MakePhoneCallPermissionRequestResultP(Sender: TObject;
      const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray);
    procedure MakePhoneCallPermissionRequestResultM(Sender: TObject;
      const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray);
  public
    { Public declarations }
    sComment2 : String;
  end;

var
  fmCustTelD: TfmCustTelD;

implementation

uses
  uDM, Globals,

{$IFDEF ANDROID}
  Androidapi.Helpers,
  Androidapi.JNI.JavaTypes,
  Androidapi.JNI.Os,
{$ENDIF}
  FMX.DialogService;

{$R *.fmx}

procedure TfmCustTelD.FormCreate(Sender: TObject);
begin
{$IFDEF ANDROID}
  FCallPhonePermission := JStringToString(TJManifest_permission.JavaClass.CALL_PHONE);
{$ENDIF}
  { test whether the PhoneDialer services are supported }
  TPlatformServices.Current.SupportsPlatformService(IFMXPhoneDialerService, FPhoneDialerService);

  txLocName.Text := Globals.CurrentLocName;
  lbJobName.Text := Globals.CurrentJobName;

  G_IsCustTelJobOK := False;
end;

// Optional rationale display routine to display permission requirement rationale to the user
procedure TfmCustTelD.DisplayRationale(Sender: TObject; const APermissions: TClassicStringDynArray; const APostRationaleProc: TProc);
begin
  // Show an explanation to the user *asynchronously* - don't block this thread waiting for the user's response!
  // After the user sees the explanation, invoke the post-rationale routine to request the permissions
  TDialogService.ShowMessage('The app needs to be able to support your making phone calls',
    procedure(const AResult: TModalResult)
    begin
      APostRationaleProc;
    end)
end;

procedure TfmCustTelD.bbnPhoneClick(Sender: TObject);
begin
  if not G_IsPhoneCall then Exit;

  if Trim(lbPhone.Text) = '' then begin
    //Please type in a telephone number.
    TDialogService.ShowMessage('전화번호를 입력하세요..');
    Activecontrol := lbPhone;
//    lbPhone.SetFocus;
    Exit
  end;
  MessageDlg('[ '+Trim(lbPhone.Text)+' ]로/으로 전화하시겠습니까?',
    TMsgDlgType.mtConfirmation,
    [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo],
    0,
    procedure(const AResult: TModalResult)
      begin
        if AResult = mrYes then begin
          if FPhoneDialerService <> nil then begin
            { if the Telephone Number is entered in the edit box then make the call, else
              display an error message }
            PermissionsService.RequestPermissions([FCallPhonePermission],
              MakePhoneCallPermissionRequestResultP, DisplayRationale)
          end else
            TDialogService.ShowMessage('PhoneDialer service not supported');
        end;
      end
    );
end;

procedure TfmCustTelD.MakePhoneCallPermissionRequestResultM(Sender: TObject;
  const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray);
begin
  // 1 permission involved: CALL_PHONE
  if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then
    FPhoneDialerService.Call(lbMobile.Text)
  else
    TDialogService.ShowMessage('Cannot make a phone call because the required permission has not been granted');
end;

procedure TfmCustTelD.MakePhoneCallPermissionRequestResultP(Sender: TObject;
  const APermissions: TClassicStringDynArray; const AGrantResults: TClassicPermissionStatusDynArray);
begin
  // 1 permission involved: CALL_PHONE
  if (Length(AGrantResults) = 1) and (AGrantResults[0] = TPermissionStatus.Granted) then
    FPhoneDialerService.Call(lbPhone.Text)
  else
    TDialogService.ShowMessage('Cannot make a phone call because the required permission has not been granted');
end;

procedure TfmCustTelD.bbnCancelClick(Sender: TObject);
begin
  if not G_IsCustTelJobOK and
   ((Trim(memComment2.Text) <> Trim(sComment2))) then begin
    ShowMessage('[입력/수정]을 먼저 하십시오.');
    Exit;
  end;
  Close;
end;

procedure TfmCustTelD.bbnInsertClick(Sender: TObject);
begin
  if not ConnectionRtn then begin
    //ShowMessage(sG_ConnectionErr); //'인터넷 접속이 원활치 않습니다.'
    Exit;
  end;
  if Trim(memComment2.Text) = '' then Exit;
  MessageDlg('자료를 [입력/수정]하시겠습니까?',
    TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0,
    procedure(const AResult: TModalResult)
    begin
      if AResult = mrYes then begin
        with dm.cdsCustTelCmdUpd do begin
          //if not dm.SQLConnection.InTransaction then //InTransaction
          //  dm.SQLConnection.BeginTransaction; //BeginTransaction
          try
            ParamByName('pLocNo').AsInteger := Globals.CurrentLocNo;
            ParamByName('pCustTelNo').AsInteger := dm.cdsCustTelCustTelNo.Value;
            ParamByName('pComment2').AsString := Trim(memComment2.Text);
            ParamByName('pComment1').AsString := Trim(memComment1.Text);
            paramByName('pJobDateTimeUpd').Value := Now; //StrToDateTime(FormatDateTime(gDateFormat+' h:nn:ss',now));
            ParamByName('pJobNameUpd').Value     := Globals.CurrentJobName;
            Execute;
          except
            ShowMessage('Error... [cdsCustTelCmdUpd]'+CR+sG_SysErr);
            Raise;
          end;
        end;

      end;
    end);
  G_IsCustTelJobOK := True;
end;

procedure TfmCustTelD.bbnMobileClick(Sender: TObject);
begin
  if not G_IsPhoneCall then Exit;

  if Trim(lbMobile.Text) = '' then begin
    //Please type in a telephone number.
    TDialogService.ShowMessage('전화번호를 입력하세요..');
    lbMobile.SetFocus;
    Exit
  end;
  MessageDlg('[ '+Trim(lbMobile.Text)+' ]로/으로 전화하시겠습니까?',
    TMsgDlgType.mtConfirmation,
    [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo],
    0,
    procedure(const AResult: TModalResult)
      begin
        if AResult = mrYes then begin
          if FPhoneDialerService <> nil then begin
            { if the Telephone Number is entered in the edit box then make the call, else
              display an error message }
            PermissionsService.RequestPermissions([FCallPhonePermission],
              MakePhoneCallPermissionRequestResultM, DisplayRationale)
          end else
            TDialogService.ShowMessage('PhoneDialer service not supported');
        end;
      end
    );
end;

procedure TfmCustTelD.TimerTimer(Sender: TObject);
begin
  lbClock1.Text := FormatDateTime('ampm h:nn:ss', now);
  lbClock2.Text := FormatDateTime(gDateFormat+' [ddd]', now);
end;

end

PhoneCallError.txt

이 댓글 링크
다른 사이트에 공유하기

  • 0

저도 PoneDialer 샘플로 테스트 진행해 봤습니다.

C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples\Object Pascal\Mobile Snippets\PhoneDialer

(오래된 버전의 안드로이드 기기에서)테스트한 결과 정상적으로 실행되고, 전화연결까지 확인했습니다.

On 2021. 11. 12. at 오전 12시 12분, 강명진 said:

Java type Jcontent_ContextCompact count not  be found.

또한, 델파이 11의 소스코드 전체에서 Jcontent_ContextCompact 로 검색 시 검색결과가 없습니다.
(해당 클래스는 델파이 11에서 사용하지 않는 것으로 예상됩니다.)

혹시 이전 버전으로 만든 프로젝트를 11버전에서 컴파일 하셨다면, 

위의 PhoneDialoer 샘플을 안드로이드 폰으로 배포해 다시한번 테스트 진행 부탁드립니다.

 

만약, 위의 이슈라면 안드로이드 라이브러리 업데이트와 관련이 있을 수 있다면, 아래 조치가 필요할 수도 있습니다.

11.0 알렉산드리아 FMX 신기능 - 안드로이드 API 30 지원과 라이브러리 업데이트

  • 안드로이드 API 30 을 타겟으로 지정 (구글 플레이 스토어의 2021년 요구사항) 지원
  • 이전의 “Support Library” 라이브러리를 새 “AndroidX” 라이브러리로 마이그레이션
  • 이전과 다른 자바 라이브러리 세트가 포함 됨에 따라 이전 버전과 호환되지 않는다. RAD 스튜디오 이전 버전에서 작성한 프로젝트를 열 때에는 다음 절차를 진행해야 한다.
    • IDE의 Projects 창으로 간다.
    • Android 32-bit 또는 Android 64-bit를 활성 타겟 플랫폼으로 지정한다.
    • Libraries 노드를 마우스 오른쪽 클릭한다.
    • Revert System Files to Default를 선택한다.

(출처: https://welcome.devgear.co.kr/rad-feature/v110/110-알렉산드리아-fmx-r3/#Android+API30)

해결이 되었는지 여부와 관련하여 진행한 방법을 남겨 주시기 바랍니다. 같은 문제에 당면한 다른 개발자들에게 도움이 됩니다.

 

이 댓글 링크
다른 사이트에 공유하기

이 토의에 참여하세요

지금 바로 의견을 남길 수 있습니다. 그리고 나서 가입해도 됩니다. 이미 회원이라면, 지금 로그인하고 본인 계정으로 의견을 남기세요.

Guest
이 질문에 답변하기...

×   서식있는 텍스트로 붙여넣기.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   이전에 작성한 콘텐츠가 복원되었습니다..   편집창 비우기

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

중요한 정보

이용약관 개인정보보호정책 이용규칙 이 사이트가 더 잘 작동하기 위해 방문자의 컴퓨터에 쿠키가 배치됩니다. 쿠키 설정 변경에서 원하는 설정을 할 수 있습니다. 변경하지 않으면 쿠키를 허용하는 것으로 이해합니다.