Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Android after splash screen black screen - Berlin


This question is answered.


Permlink Replies: 19 - Last Post: Apr 3, 2018 2:22 AM Last Post By: Per Lindholt
Md. Shariful Al...

Posts: 70
Registered: 9/9/01
Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 6:12 AM
I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is showing. How to avoid it?
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 9:44 AM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
Am 04.03.2017 um 15:12 schrieb Md. Shariful Alam Khan:
I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is showing. How to avoid it?

Afaik not possible. You might request this via QP from EMBT.

Greetings

Markus
steven chesser

Posts: 401
Registered: 4/13/09
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 11:08 AM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
I've been bothered by this also ... been trying to see if any tricks to speed it up. Have had a few complaints on how long it takes to get to the 1st form.

I have two datamodules that create ( one is just for handling settings and such ) the other contains a few FireDac SQL objects and stuff.. pretty light weight.

I've stripped it down as far as I can on what is needed to start up the app, but it still has roughly 6 second black screen before the main form shows.
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 12:45 PM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is
showing. How to avoid it?

You mean before your main screen shows? For how long?

On my Nexus 5X, the black screen shows for a barely noticeable amount of time. If it's showing for longer on a similar
device for you, it's possible you're holding up the startup process too long. Make sure you respond to the BecameActive
application event, and do your startup work there.

If you end up deploying the same app to iOS, you'll also find it's less likely to be rejected in the app store.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
steven chesser

Posts: 401
Registered: 4/13/09
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 2:14 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is
showing. How to avoid it?

You mean before your main screen shows? For how long?

On my Nexus 5X, the black screen shows for a barely noticeable amount of time. If it's showing for longer on a similar
device for you, it's possible you're holding up the startup process too long. Make sure you respond to the BecameActive
application event, and do your startup work there.

If you end up deploying the same app to iOS, you'll also find it's less likely to be rejected in the app store.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

For myself there only work being done on main form create, is to assigning a stylebook ... which removed, doesn't change anything.
There was an onShow event code... removed that too... no dice. I stripped out everything not needed and still takes ~5 seconds to get
to the main form after the splash.

Small 1 form, 1 button , no code program takes ~1.5 second range to go to the main form after splash screen goes black.

Pondering just if bigger the program in general, longer it takes to load... maybe some stuff out of my control just getting in the way some how?

I've spent probably 40 hrs in total try to figure a way to speed up start up on my production app with no good results yet.

Compared to the native android apps of similar size, its literally instant loading... so something in the Delphi code is dragging things down but i dont know enough to track it down.
Md. Shariful Al...

Posts: 70
Registered: 9/9/01
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 2:42 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is
showing. How to avoid it?

You mean before your main screen shows? For how long?

On my Nexus 5X, the black screen shows for a barely noticeable amount of time. If it's showing for longer on a similar
device for you, it's possible you're holding up the startup process too long. Make sure you respond to the BecameActive
application event, and do your startup work there.

If you end up deploying the same app to iOS, you'll also find it's less likely to be rejected in the app store.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

After splash screen close and main form to show with a empty form tooks around 5 seconds. This is not just Berlin issue. I did notice that since Delphi supported Android. All other apps showing their main form just immediately splash screen close. I didn't use any form for splash screen all I used Delphi's default splash technology.
steven chesser

Posts: 401
Registered: 4/13/09
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 3:49 PM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
Md. Shariful Alam Khan wrote:
Dave Nottage wrote:
Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is
showing. How to avoid it?

You mean before your main screen shows? For how long?

On my Nexus 5X, the black screen shows for a barely noticeable amount of time. If it's showing for longer on a similar
device for you, it's possible you're holding up the startup process too long. Make sure you respond to the BecameActive
application event, and do your startup work there.

If you end up deploying the same app to iOS, you'll also find it's less likely to be rejected in the app store.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

After splash screen close and main form to show with a empty form tooks around 5 seconds. This is not just Berlin issue. I did notice that since Delphi supported Android. All other apps showing their main form just immediately splash screen close. I didn't use any form for splash screen all I used Delphi's default splash technology.

This all got me thinking .... I did have one datamodule that was doing some work on create. It was loading the style sheet file resource. I did this long ago in
the very beginning and forgot all about it. I tried to make my form/datamodule creates very light...

procedure TdmSettings.DataModuleCreate(Sender: TObject);
var
  vResourceStream: TResourceStream;
begin
  StyleBook := TStylebook.Create(nil); // style book is a resource file compiled into program
   vResourceStream := TResourceStream.Create(HInstance, 'cpstyle', RT_RCDATA);
   vResourceStream.Position := 0;
   StyleBook.LoadFromStream(vResourceStream);
end;


With this, black screen for 5-6 seconds on startup after the splash goes away.

Remove it, and ~2 seconds if that of black screen now. I guess loading the stylebook up with data takes a long process. Now to figure out a way around this for myself.
Md. Shariful Al...

Posts: 70
Registered: 9/9/01
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 10:02 PM   in response to: steven chesser in response to: steven chesser
steven chesser wrote:
Md. Shariful Alam Khan wrote:
Dave Nottage wrote:
Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is
showing. How to avoid it?

You mean before your main screen shows? For how long?

On my Nexus 5X, the black screen shows for a barely noticeable amount of time. If it's showing for longer on a similar
device for you, it's possible you're holding up the startup process too long. Make sure you respond to the BecameActive
application event, and do your startup work there.

If you end up deploying the same app to iOS, you'll also find it's less likely to be rejected in the app store.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

After splash screen close and main form to show with a empty form tooks around 5 seconds. This is not just Berlin issue. I did notice that since Delphi supported Android. All other apps showing their main form just immediately splash screen close. I didn't use any form for splash screen all I used Delphi's default splash technology.

This all got me thinking .... I did have one datamodule that was doing some work on create. It was loading the style sheet file resource. I did this long ago in
the very beginning and forgot all about it. I tried to make my form/datamodule creates very light...

procedure TdmSettings.DataModuleCreate(Sender: TObject);
var
  vResourceStream: TResourceStream;
begin
  StyleBook := TStylebook.Create(nil); // style book is a resource file compiled into program
   vResourceStream := TResourceStream.Create(HInstance, 'cpstyle', RT_RCDATA);
   vResourceStream.Position := 0;
   StyleBook.LoadFromStream(vResourceStream);
end;


With this, black screen for 5-6 seconds on startup after the splash goes away.

Remove it, and ~2 seconds if that of black screen now. I guess loading the stylebook up with data takes a long process. Now to figure out a way around this for myself.

I tested with blank form without using any component, any code. It also tooks 5-6 seconds on startup.
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 10:36 PM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
Md. Shariful Alam Khan wrote:

I tested with blank form without using any component, any code. It also tooks 5-6 seconds on startup.

Is that while using the debugger, or just running the app on the device? What kind of device is it?

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Md. Shariful Al...

Posts: 70
Registered: 9/9/01
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2017 11:52 PM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
Md. Shariful Alam Khan wrote:

I tested with blank form without using any component, any code. It also tooks 5-6 seconds on startup.

Is that while using the debugger, or just running the app on the device? What kind of device is it?

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog

I am testing in Nexus 5 with Android 6.1
Ken Randall

Posts: 130
Registered: 11/12/99
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 5, 2017 1:46 AM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
Create your own splash screen form and use it instead.

Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash
screen for a few seconds a black screen is showing. How to avoid it?
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 5, 2017 2:56 AM   in response to: Ken Randall in response to: Ken Randall
Am 05.03.2017 um 10:46 schrieb Ken Randall:
Create your own splash screen form and use it instead.

Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash
screen for a few seconds a black screen is showing. How to avoid it?

How?
The black screen is between the regular splash screen and the drawing of
the first app screen.

QUestion is what FMX does a that time and whether it could simply show
the regular splash screen longer to hide that black period.

Greetings

Markus
Ken Randall

Posts: 130
Registered: 11/12/99
Re: Android after splash screen black screen - Berlin
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 5, 2017 4:28 AM   in response to: Markus Humm in response to: Markus Humm
In your project source create the splash form instead of the main form
and then have the splash form create your mainform e.g.

Application.Initialize;
{$IFDEF ANDROID}
Application.CreateForm(TSplashForm, SplashForm);
Application.Run;
{$ELSE}
Application.CreateForm(TMainForm, MainForm);
Application.Run;
{$ENDIF}

In the splash form have something similar to:

procedure TSplashForm.FormClose(Sender: TObject; var Action:
TCloseAction);
begin
Action:=TCloseAction.caFree;
end;

procedure TSplashForm.FormCreate(Sender: TObject);
begin
StartupTimer.Enabled := false;
StartupTimer.Interval := 500; // can be changed to improve startup
speed in later releases
end;

procedure TSplashForm.LoadMainForm;
begin
with TMainForm.Create(Application) do
Show;
Application.MainForm:=MainForm;
Close;
end;

procedure TSplashForm.SplashImagePaint(Sender: TObject; Canvas:
TCanvas; const ARect: TRectF);
begin
StartupTimer.Enabled:=not FInitialized;
end;

procedure TSplashForm.StartupTimerTimer(Sender: TObject);
begin
StartupTimer.Enabled:=False;
if not FInitialized then
begin
FInitialized:=True;
LoadMainForm;
end;
end;

Markus Humm wrote:

Am 05.03.2017 um 10:46 schrieb Ken Randall:
Create your own splash screen form and use it instead.

Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash
screen for a few seconds a black screen is showing. How to avoid
it?

How?
The black screen is between the regular splash screen and the drawing
of the first app screen.

QUestion is what FMX does a that time and whether it could simply show
the regular splash screen longer to hide that black period.

Greetings

Markus
Md. Shariful Al...

Posts: 70
Registered: 9/9/01
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 5, 2017 5:53 AM   in response to: Ken Randall in response to: Ken Randall
Ken Randall wrote:
In your project source create the splash form instead of the main form
and then have the splash form create your mainform e.g.

Application.Initialize;
{$IFDEF ANDROID}
Application.CreateForm(TSplashForm, SplashForm);
Application.Run;
{$ELSE}
Application.CreateForm(TMainForm, MainForm);
Application.Run;
{$ENDIF}

In the splash form have something similar to:

procedure TSplashForm.FormClose(Sender: TObject; var Action:
TCloseAction);
begin
Action:=TCloseAction.caFree;
end;

procedure TSplashForm.FormCreate(Sender: TObject);
begin
StartupTimer.Enabled := false;
StartupTimer.Interval := 500; // can be changed to improve startup
speed in later releases
end;

procedure TSplashForm.LoadMainForm;
begin
with TMainForm.Create(Application) do
Show;
Application.MainForm:=MainForm;
Close;
end;

procedure TSplashForm.SplashImagePaint(Sender: TObject; Canvas:
TCanvas; const ARect: TRectF);
begin
StartupTimer.Enabled:=not FInitialized;
end;

procedure TSplashForm.StartupTimerTimer(Sender: TObject);
begin
StartupTimer.Enabled:=False;
if not FInitialized then
begin
FInitialized:=True;
LoadMainForm;
end;
end;

Markus Humm wrote:

Am 05.03.2017 um 10:46 schrieb Ken Randall:
Create your own splash screen form and use it instead.

Md. Shariful Alam Khan wrote:

I am creating one Android application with Berlin. After the splash
screen for a few seconds a black screen is showing. How to avoid
it?

How?
The black screen is between the regular splash screen and the drawing
of the first app screen.

QUestion is what FMX does a that time and whether it could simply show
the regular splash screen longer to hide that black period.

Greetings

Markus

Perfect solution. Thank you very much. Every body must follow it.
Ken Randall

Posts: 130
Registered: 11/12/99
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 5, 2017 6:07 AM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
I'm pleased it helped. I can't take credit for this as I got the idea
from somwhere else but can't remember where.

Md. Shariful Alam Khan wrote:

Perfect solution. Thank you very much. Every body must follow it.
Malcolm Taylor

Posts: 148
Registered: 7/16/01
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 6, 2017 4:49 AM   in response to: Ken Randall in response to: Ken Randall
Ken Randall wrote:

I'm pleased it helped. I can't take credit for this as I got the idea
from somwhere else but can't remember where.

Looks very close to an article by Uwe Raabe. :)
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 5, 2017 10:28 AM   in response to: Ken Randall in response to: Ken Randall
Hello,

thanks for sharing this idea.
Will try it.

Greetings

Markus
Jeremy North

Posts: 402
Registered: 9/20/99
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 7, 2017 2:41 PM   in response to: Ken Randall in response to: Ken Randall
Ken Randall wrote:
Create your own splash screen form and use it instead.

This is what I've done for some of my apps that have to do things on startup so viewing the main form is delayed.

Please need to remember it isn't just the executing of code, if you main forms DFM is very heavy streaming that content in can also take time.
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 7, 2017 4:34 PM   in response to: Jeremy North in response to: Jeremy North
Please need to remember it isn't just the executing of code, if you main forms DFM is very heavy streaming that content in can also take time.

Good point. I have virtually nothing in my main form other than a TTabControl, which I use to show frames inside of, and none of those are shown til BecameActive fires.

--
Dave Nottage [TeamB]
Delphi Worlds blog: http://www.delphiworlds.com/blog
Per Lindholt

Posts: 2
Registered: 3/16/00
Re: Android after splash screen black screen - Berlin  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 3, 2018 2:22 AM   in response to: Md. Shariful Al... in response to: Md. Shariful Al...
Md. Shariful Alam Khan wrote:
I am creating one Android application with Berlin. After the splash screen for a few seconds a black screen is showing. How to avoid it?
This is a "Berlin" problem. With Tokyo this is not a problem.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02