O'Reilly logo

Xamarin Studio for Android Programming: A C# Cookbook by Mathieu Nayrolles

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required