Background Services in Mono for Android: Listing 2
Overriding OnStartCommand()
- By Greg Shackles
- 07/10/2012
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
string command = intent.GetStringExtra(CommandExtraName);
switch (command)
{
case PlayCommand:
startPlaying();
break;
case StopCommand:
stopPlaying();
break;
default:
return base.OnStartCommand(intent, flags, startId);
}
return StartCommandResult.Sticky;
}
About the Author
Greg Shackles is a Senior Software Engineer at OLO Online Ordering, based in New York City. His book, Mobile Development with C# (O'Reilly), covers how to get started building iOS, Android and Windows Phone apps with C#. As an active member of the community, Greg speaks regularly at many user groups and developer events. Outside of technology, Greg is obsessed with heavy metal, baseball, and craft beer, sometimes in combination, as well as an aspiring homebrewer. You can find him online on his blog, gregshackles.com, or on Twitter: @gshackles.