Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This solution gets you the following:</p> <ul> <li>Immediate display of the splash screen</li> <li>Removal of splash screen the exact time the "main" activity is launched (main activity replaces the splash activity)</li> </ul> <p>In OnCreate, SetContentView is called to get the splash screen up, and then the worker thread is kicked off, which runs the slow processing data initialization stuff.</p> <p>This way, the spalsh screen is displayed without delay. The last statement in the worker thread kicks off the "main" app/activity, which will have its DB &amp; data all ready for access. Calling StartActivity() from OnCreate (ie, after initializeDataWorker.Start()), will cause MainActivity to run before/while the DB is being created and/or data is being fetched, which is usually not desireable).</p> <p>This solution lacks a way to remove the splash screen from the backstack. When I get around to implementing this functionality I'll update it.</p> <pre><code>namespace Mono.Droid { [Activity( Label = "Splash Activity", MainLauncher = true, Theme = "@android:style/Theme.Black.NoTitleBar", Icon = "@drawable/icon", NoHistory = false)] public class SplashActivity : Activity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SplashLayout); Thread initializeDataWorker = new Thread(new ThreadStart(InitializeData)); initializeDataWorker.Start(); } private void InitializeData() { // create a DB // get some data from web-service // ... StartActivity(typeof(MainActivity)); } } } </code></pre>
    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.
    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