Implementing a started service

In this recipe, we will create and explain all the necessary code to implement a started service. A started service is a service that performs heavy tasks in the background and doesn't offer the possibility to communicate with it through an interface.

Getting ready

Create a new solution named Services and open it.

How to do it...

We will now see how to implement a service:

  1. Create a new C# class named MyService.cs.
  2. Add using Android.App, using Android.Util, and using System.Threading at the beginning of the class.
  3. Specify that your class extends the Service class, and use the Service attribute, shown as follows:
    using System; using Android.App; using Android.Util; using System.Threading; namespace Services { [Service] public ...

Get Xamarin Studio for Android Programming: A C# Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.