Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do a well-coded splash screen
    primarykey
    data
    text
    <p>We all know there is lots of tutorials about how to do a splash screen on Android. But we also know those are <em>pseudo-splashscreens</em>. I searched for many and I always saw <code>Thread.sleep(x)</code>. That's not well coded, this is just to make the app beauty and looking like a professional app, that's not what I want! <br> Another problem with those splash screens is that they don't solve my problem because they only show it <strong>after</strong> the activity start and show the content view.</p> <p>I have an app that does lots of things while initializing and when the app starts the user sees a black screen for a few seconds, enough time to annoy. So that's why I want to show a well-coded splash screen that removes that black screen that appears before the content view has been set. </p> <p>I tried something. I included the splash screen (a <code>RelativeLayout</code>) into the layout that is set in the <code>MainActivity</code>, but as far as I know Android only shows the content after everything has been loaded, so if I'm trying to show some view from the content view I have to wait until everything has finished. Still, I'll send my code, it can help somehow...</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new SplashTask().execute(); } private class SplashTask extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { initializeViews(); mSplashScreen.setVisibility(View.VISIBLE); } @Override protected Void doInBackground(Void... params) { return null; } @Override protected void onPostExecute(Void params) { Standard.Initiate(MainActivity.this); verifyListStats(); loadListAdapters(); setOnClickListeners(); mSplashScreen.setVisibility(View.GONE); } } </code></pre> <p>I tried to load some resources in <code>doInBackground(...)</code> but because I do some operations in <code>onResume()</code> that need those resources I can't do it (or at least I think I can't).</p> <p>Any idea? I heard about a built-in mechanism similar to iOS launch images, perhaps that can be a way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload