You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
using Android.App;
|
|
using Android.Content;
|
|
using Android.OS;
|
|
using Android.Support.V7.App;
|
|
using Android.Util;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Demo.Droid
|
|
{
|
|
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
|
|
public class SplashActivity : AppCompatActivity
|
|
{
|
|
private static readonly string TAG = "X:" + typeof(SplashActivity).Name;
|
|
|
|
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
|
|
{
|
|
base.OnCreate(savedInstanceState, persistentState);
|
|
Log.Debug(TAG, "SplashActivity.OnCreate");
|
|
}
|
|
|
|
// Launches the startup task
|
|
protected override void OnResume()
|
|
{
|
|
base.OnResume();
|
|
Task startupWork = new Task(() => { SimulateStartup(); });
|
|
startupWork.Start();
|
|
}
|
|
|
|
// Simulates background work that happens behind the splash screen
|
|
private async void SimulateStartup()
|
|
{
|
|
Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
|
|
await Task.Delay(8000); // Simulate a bit of startup work.
|
|
Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
|
|
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
|
|
}
|
|
public override void OnBackPressed() { }
|
|
}
|
|
} |