Differently form iOS, Android lacks an initial splash bitmap, but you can build one to improve startup time (or its perception).

Differently from iOS, Android lacks an initial splash bitmap, but you can build one to improve startup time (or its perception). In fact, it is not that you can make things faster, but the user will get the initial screen in a shorter time than he or she will get the main form, if this takes time to initialize. You'd want to do this when the main form has many controls, requires database or file access, needs to load images, access to remote data, or anything that takes extra time. In all of these scenarios, an initial splash screen (like the one I've used in my Play Store app covered on log.marcocantu.com/blog/my_son_first_play_store_app.html) will be handy.

There are two approaches I can think of. One would be an initial screen that is never displayed again, the second would be a splash screen that acts as main menu for the application, and can be used over time. For my app, I implemented the second approach, and this is what I'm going to cover. Also, in my specific case, there are two alternative secondary forms you can go to from the main splash screen form.

First, we need to have the initial form show fast. This form should have little or no initialization code. It might have an image, covering most of its surface, plus some buttons (initially not visible, in my case). Here is the actual form at design time, and below its form definition:

object Form2: TForm2 object ImageControl1: TImageControl Align = alClient Bitmap = ... end object GridPanelLayout1: TGridPanelLayout Align = alBottom Height = 71.000000000000000000 ColumnCollection = < item Value = 50.000000000000000000 end item Value = 50.000000000000000000 end> ControlCollection = < item Column = 0 Control = Button1 Row = 0 end item Column = 1 Control = Button2 Row = 0 end> RowCollection = < item Value = 100.000000000000000000 end> object Button1: TButton Align = alClient Text = 'Collection' Visible = False end object Button2: TButton Align = alClient Text = 'New Figuret' Visible = False end end object ToolBar1: TToolBar Height = 48.000000000000000000 object Label1: TLabel Align = alClient Text = 'My Mini Figures' TextAlign = taCenter end end object Timer1: TTimer Interval = 100 OnTimer = Timer1Timer end end



There are a few things to notice in this FMX file definition:

There is a toolbar with a label covering its surface (alClient) and centered text, which acts as a title

There is an image covering the entire screen surface (but the toolbar and the bottom area)

There are two buttons at the bottom. To make them half of the screen each, I added them to a GridPanelLayout with a single row and two columns, using 50% of the width each. The two buttons are aligned to the area of each of the two cells.

A timer, with a short interval

Besides the UI elements, what is important for this splash screen to show faster, is to avoid creating the other forms at startup (in the main project file). However, you cannot create the secondary forms in the OnCreate handler of the main form (as you won't see it on screen until after the OnCreate event handler has finished executing). One options would have been to start a secondary thread. Another (simpler) option I've used in my code is to rely on a timer. After the form has been created and displayed, the timer will kick in (possibly waiting a few milliseconds) and execute the following code:

procedure TForm2.Timer1Timer(Sender: TObject); begin Form1 := TForm1.Create(Application); Form4 := TForm4.Create(Application); Button2.Visible := True; Button1.Visible := True; Timer1.Enabled := False; end;

As you can see, when the timer fires the app creates the two secondary forms (which takes a few seconds on my phone, as the program loads 60 or so images from files) and enables the two buttons. This delay and the actual initialization of the real mani form takes place while the splash screen is visible. Without this trick, the user will have a black screen... and the Android system might also indicate the app is not responding and refuse to start it.

Needless to say you'll have to adapt this splash screen code to your specific scenario, but I think it is worth using this approach in any application with a non trivial initialization. Again, you can test this in action by getting the app from the Play Store at https://play.google.com/store/apps/details?id=com.marcocantu.MyMiniFigures.