0

When I launch my app, if there has been x failed attempts to get into the main game, I launch a "SafeMode activity", where they then have options to reset or delete save data etc, which I launch like this from my "Main" activity:

Intent intent = new Intent(MainActivity.this, SafeModeActivity.class);
startActivity(intent);

I have a button in there to exit safe mode and return to the main app, which then calls this (boolean set to false so we don't enter safe mode again):

MainActivity.mbEnterSafeMode = false;
finish();

This works fine except I get a black screen for around 15 seconds before anything displays on "Main". I've stepped through the code and OnRestart() and onStart() take virtually no time at all and if I break after this point, there is no call stack.

I've seen posts on this kind of thing but most seem to mention onCreate() taking a while but that has already been called in my case as I'm going back to the activity. Other people mention adding a "No Display" theme but I'm not sure how that helps me.

My question is what is happening after onStart() please?

Note that I also get this delay when Main is started normally but it doesn't matter as this is before anything has displayed but when returning from safe mode, something was displaying, then I get my black screen and then the title screen.

Thanks, Chris.

Chris Moore
  • 157
  • 1
  • 3
  • 12
  • Do you do some work at onResume method? – idog Feb 06 '14 at 16:45
  • Thanks for your reply @idog. The onResume method doesn't do much and completes very quickly. I just realised what the problem is and it's not to do with these android methods. I'll post it now as an answer. – Chris Moore Feb 06 '14 at 17:36

1 Answers1

0

Turns out this wasn't anything to do with the Android functions. Basically, before any rendering is done on the first screen, there is a function to initialise stuff so while that's happening nothing renders. So I think I just need to separate that out to make sure only stuff necessary for the render happens immediately and then other init'ing is done afterwards.

Chris Moore
  • 157
  • 1
  • 3
  • 12
  • Could you please elaborate? what functions did you change? – Royi Benyossef Apr 24 '14 at 07:19
  • 1
    @royiby Basically, when control returned to my app, I was initialising a load of stuff in the first screen init function before doing any rendering, hence the black screen while that was happening. So I stripped out anything not necessary for rendering at that point (loading profile, initialising batch, model and resource managers etc) and just did that in the init function so I could at least render something while everything else was being initialised (initially just a background texture with some loading text) and then initialised everything else. Hope that makes sense, Chris. – Chris Moore Apr 24 '14 at 15:02