Advertisement
banyucenter

SplashActivity.cs

Nov 4th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Android.App;
  7. using Android.Content;
  8. using Android.OS;
  9. using Android.Runtime;
  10. using Android.Support.V7.App;
  11. using Android.Util;
  12. using Android.Views;
  13. using Android.Widget;
  14.  
  15. namespace PariwisataApp
  16. {
  17. [Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true)]
  18. public class SplashActivity : Activity
  19. {
  20.     static readonly string TAG = "X:" + typeof(SplashActivity).Name;
  21.  
  22.     public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
  23.     {
  24.         base.OnCreate(savedInstanceState, persistentState);
  25.         Log.Debug(TAG, "SplashActivity.OnCreate");
  26.     }
  27.  
  28.     // Launches the startup task
  29.     protected override void OnResume()
  30.     {
  31.         base.OnResume();
  32.         Task startupWork = new Task(() => { SimulateStartup(); });
  33.         startupWork.Start();
  34.     }
  35.  
  36.     // Simulates background work that happens behind the splash screen
  37.     async void SimulateStartup()
  38.     {
  39.         Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
  40.         await Task.Delay(8000); // Delay waktu menuju MainActivity
  41.         Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
  42.         StartActivity(new Intent(Application.Context, typeof(LoginActivity)));
  43.     }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement