Simple Firemonkey mobile application for Android step-by-step

Today I'll show you how to create simple mobile application for Android using Delphi in few minutes. And if you have an Apple device, you'll only translate it for iOS.

All the development will be carried out on Windows platform as a 32bit application, only the result will be adapted for target device or platform. Our application allows to enter ID and returns business record for given company (business name, address and more) in JSON format – result will be processed and displayed within an application.


  • Delphi with Mobile development
  • an Android device on which USB debugging is enabled

Let's start

In first step, create a new application, i.e. select Multi Device Application and Header/Footer layout. As soon as first step is done, save basic app anywhere you like.

Mobile Development

Mobile Development

Several last versions allow Firemonkey to use View technology, where user can define exact look of the app on various resolutions (we define Master and customize it then). Working with Master only will be enough for us because application adapts itself and detailed resolution settings won't be necessary.

Mobile Development

View options – Master enoughs

Now is pretty important to set Layout – it means assure app to customize target device in case if layout for various resolutions is not set. We can choose among many Layout options (you can imagine as a panel with certain behavior), but let's use TListBox component (another reasonable option is MultiView or TListView).

Mobile Development

To be frank, do forget VCL based TListBox, this is strongly different solution. Each Item within the list can be a component with type at pleasure, with different style, and can contain further miscellaneous components.

ListBox in action

Choose ListBox and place it onto the Form with setting Align=alClient.


Now we will insert particular items which will represent a cornerstone of our user interface. Starting with title (I've already inserted it there).

Mobile Development

In the next step add an Item on ListBox through context menu:

Mobile Development

and set desired style:

Mobile Development

Finally, type title text.


Intended look is depicted below:

Mobile Development

So we insert TListBoxItem ten times and set Style if necessary. Edit field is common TEdit but with special style and Align set to alCenter (however, you can use any other align method).

How do we create delete key for TEdit? Simply click at TEdit and add TClearEditButton by means of context menu, that's all.

Mobile Development

Please observe tree structure regarding TEdit. FireMonkey allows to combine components as you like and as you need. Styles what are able to "do miracles" are additional value too.

Well, we've created basic user interface. This UI will be adapted according to target platform while compiling.

Main programme

At this moment, we can compile application for target platform, i.e. for Windows, iOS, Mac OSX or Android. I strictly recommend to develop completely using Windows target and tune up e.g. for Android – it's more comfortable regarding speed of compiling and deployment.

Mobile Development

You can see I wrote no-one line of code until now and we'll fix it just now. How it will work? We are about to use certain Czech local webservice that can return business information for given company (based on its ID, so called IČO) in JSON format. So we simply create URL, download data using THTTPClient Delphi component and parse and display returned data by means of multiplatform System.JSON.

Code for Button

  //  Windows,
{$R *.fmx}

procedure THeaderFooterForm.Button1Click(Sender: TObject);
  oClient: THTTPClient;
  oStream: TStringStream;
  iStatus: Integer;
  sResponse: string;
  oJsonValue: TJSONValue;
  s: string;
  o: TObject;
  ciLen = length('ico_back('); // odpoved obsahuje kus JS
  oClient := THTTPClient.Create;
  oStream := TStringStream.Create;
    // pro ladeni
    iStatus := oClient.Get('', oStream, nil).StatusCode;
//    iStatus := oClient.Get(''+edtICO.Text+'.js', oStream, nil).StatusCode;
    iStatus := iStatus div 200;
    if iStatus <> 1 then
      edtName.Text := 'Error:'+iStatus.ToString;
    sResponse := oStream.DataString.Substring(ciLen);
    sResponse := sResponse.Remove(Length(sResponse) - 1);
    oStream.DisposeOf; // ignoruj ARC 
 'ico_back({id:''25247484'',count:1,name:''AB - AKCIMA, s.r.o.'',
 addr_main:{city:''Cheb'',citypart:''Cheb'',street:''Havl\u00ED\u010Dkova 1803/2'',
  sResponse := NormaliseJSON(sResponse);
//  Windows.MessageBox(0, Pchar(sResponse), nil, 0);

  oJsonValue := TJSONObject.parseJSONValue(sResponse);
  if oJsonValue is TJSONObject then
    s := TJSONObject(oJsonValue).Values['id'].Value;
    edtName.Text := TJSONObject(oJsonValue).Values['name'].Value;
    o := TJSONObject(oJsonValue).Values['addr_main'];
    if o is TJSONObject then
      edtAdr1.Text := TJSONObject(o).Values['street'].Value;
      edtAdr2.Text := TJSONObject(o).Values['citypart'].Value;
      edtPost.Text := TJSONObject(o).Values['zip'].Value;

First part of code downloads JSON, second one goes through and returns requested information. It's straightforward except NormaliseJSON which partially edits returned JSON.

function THeaderFooterForm.NormaliseJSON(const s: string): string;
  c: char;
  bInQuote: Boolean;
  Result := '';
  bInQuote := False;
  for c in s do
    if c = '''' then
      bInQuote := not bInQuote;
      Result := Result + '"';
    if bInQuote then
      Result := Result + c
     if CharInSet(c, ['{', ',']) then
      Result := Result + c+ '"'
     if CharInSet(c, [':']) then
      Result := Result + '"'+c
      Result := Result + c
  Result := Result + '';

Try it out for Windows, translate for Android and we've done.


Be aware of zero-terminated strings in mobile applications – if you do not want to use switch which turns it off, simply remember that all the functions called by String.xxxx start from zero.

Mobile Development

Size of Application

Remove all unnecessary parts from your app via the Project Manager. Final application compile as a Release, package size is in my case 6 119 782 bytes.

Mobile Development

It should have been video tutorial initially but it wouldn't be good. In addition, I like rather textual instruction so I'm sorry for that :-)

About the Author

Ing. Radek Červinka
Embarcadero MVP