Put Some Cyanogen in Your Xamarin Apps

Jon Dick

CyanogenMod SDK on XamarinCyanogenMod is an enhanced open source firmware distribution of Android that offers customizable features and options. Cyanogen continues to grow in popularity, and they recently introduced an early version of their platform SDK. Cyanogen launched this SDK by seeding it with the Quick Settings Tile API. Cyanogen’s Leigh Momii and Adnan Begovic say they hope to inspire the Cyanogen community to understand what’s possible and think up additional APIs to add to CyanogenMod.

Quick Settings Custom Tiles are a great way to add an easy, global way for your users to do things like toggle a feature of your app on and off.

Adding a Quick Settings Custom Tile to your Xamarin.Android app is easy with the new CyanogenMod SDK for Xamarin in the Xamarin Component Store.

After you’ve added the component to your project, you can use the CustomTile.Builder to build your tile:

var customTile = new CustomTile.Builder (this)
    .SetOnClickIntent (pendingIntent)
    .SetContentDescription ("Monkey Toggler")
    .SetLabel ("Monkeys " + States.Off)
    .SetIcon (Resource.Drawable.ic_launcher)
    .Build ();

Once you’ve created your custom tile, you can publish it with the CMStatusBarManager:

CMStatusBarManager.GetInstance (this)
    .PublishTile (CustomTileId, customTile);

The CustomTileId is a unique ID associated with your tile. When you publish a new tile with the same ID, it will update the existing tile under that identifier, making it possible to change the appearance based on the current state of your app.

Don’t worry if your app isn’t running on CyanogenMod – in such a case, the SDK will gracefully fail. Rather than seeing exceptions, Custom Tiles won’t be published on platforms that don’t support it, so you can feel safe adding this feature to your app!

This is only the first feature that CyanogenMod has released in its Platform SDK, and we’re excited to see what new features the CyanogenMod community will add in the near future. Go grab the CyanogenMod SDK for Xamarin component today and give your Cyanogen users a better experience!

0 comments

Discussion is closed.

Feedback usabilla icon