Fortunately, there is a solution: You can make your app compile for both Android and Windows, and debug most functionality as a Windows app. These guidelines can help you:
- Put all Android-specific code into units that have a name that starts with "Android". For instance, if you want to send an SMS, put the code for that into an AndroidSms.pas unit.
- Use {$IFDEF ANDROID} for code that you want to execute only when deployed on Android.
- Exclude Android* units from the dpr file
Here is an example of a uses-clause that compiles with both Android and Windows:
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
{$IFDEF ANDROID}
AndroidSms,
{$ENDIF}
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls;
Here is an example of some code that does one thing on Android, and another thing when compiling to Windows:
procedure TForm2.SendSMS (target,messagestr:string);
begin
{$IFDEF ANDROID}
AndroidSms.SendSms(target,messagestr);
{$ELSE}
Memo1.Lines.Add (target+': '+messagestr);
{$ENDIF}
end;
As you can see in this last example, the Windows version will visualize to the programmer, that the app was meant to send an SMS at this point, instead of actually doing it. This speeds up testing a lot.
Waw, Great site. I have read your article. really your have shared your natural Idea. I like your article very much. I think it is the best Webdesign site. Everyone can understand everything easily.
ReplyDeleteApp Programmierung
MEGA AGES and MEGA AGES ANNOUNCE - Jammy
ReplyDeleteSega 시흥 출장샵 AGES and MEGA AGES ANNOUNCE: a new 동해 출장안마 retro 안동 출장안마 game from the well known game studio, MEGA 시흥 출장안마 AGES and MEGA AGES ANNOUNCE: a new retro 진주 출장마사지 game from the well known game studio,