SHARE
TWEET

Untitled

a guest Apr 25th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. using Android.App;
  4. using Android.Content.PM;
  5. using Android.Runtime;
  6. using Android.OS;
  7. using AndroidX.Work;
  8.  
  9. namespace BackgroundWork.Droid
  10. {
  11.     [Activity(Label = "BackgroundWork", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
  12.     public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
  13.     {
  14.         protected override void OnCreate(Bundle savedInstanceState)
  15.         {
  16.             TabLayoutResource = Resource.Layout.Tabbar;
  17.             ToolbarResource = Resource.Layout.Toolbar;
  18.  
  19.             base.OnCreate(savedInstanceState);
  20.             global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
  21.             LoadApplication(new App());
  22.             Xamarin.Essentials.Platform.Init(this, savedInstanceState);
  23.             var r = PeriodicWorkRequest.Builder.From<LocalWorker>(TimeSpan.FromSeconds(5)).Build();
  24.  
  25.             WorkManager.Instance.Enqueue(r);
  26.         }
  27.  
  28.         public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
  29.         {
  30.             Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
  31.  
  32.             base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
  33.         }
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top