To track the location of users in the background, we need to create a background job. Follow these steps:
- In the Android project, create a new class called LocationJobService in the Services folder.
- Make the class public and add Android.App.Job.JobService as a base class.
- Implement the OnStartJob and OnStopJob abstract methods, as shown in the following code:
public class LocationJobService : JobService
{
public override bool OnStopJob(JobParameters @params)
{
return true;
}
public override bool OnStartJob(JobParameters @params)
{
return true;
}
}
All the services in the Android app need to be added to the AndroidManifest.xml file. We don't have to do this manually; instead, we can add an attribute to the class, which will then be generated in the AndroidManifest.xml file. We will use the Name and Permission properties to set the required information, as shown in the following code:
[Service(Name...