Background Services in Mono for Android: Listing 2

Overriding OnStartCommand()

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, Microsoft MVP, Xamarin MVP, is a Principal Engineer at Olo. He hosts the Gone Mobile podcast, organizes the NYC Mobile .NET Developers Group, and wrote Mobile Development with C# (O'Reilly). Greg is obsessed with heavy metal, baseball, and craft beer (he’s an aspiring home brewer). Contact him at Twitter @gshackles.

comments powered by Disqus

Featured

Subscribe on YouTube