Last active
April 15, 2019 15:31
-
-
Save pictos/d56e874ee4976ee196ec7802e30f2cdf to your computer and use it in GitHub Desktop.
Using Work in Xamarin.Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Android.Content; | |
using Android.Util; | |
using AndroidX.Work; | |
using Xamarin.Essentials; | |
namespace BackgroundWork.Droid | |
{ | |
public class LocalWorker : Worker | |
{ | |
public LocalWorker(Context context, WorkerParameters workerParams) | |
: base(context, workerParams) | |
{ | |
} | |
public override Result DoWork() | |
{ | |
Location local = null; | |
var request = new GeolocationRequest(GeolocationAccuracy.Default); | |
local = Geolocation.GetLocationAsync(request).GetAwaiter().GetResult(); | |
Log.Info("Teste", $"Trabalho funcionando - {DateTime.Now}"); | |
Log.Info( "Local", $"Latitude:{local?.Latitude}, Longitude:{local?.Longitude}"); | |
return new Result.Retry(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment