How to: add a settings screen to Android wallpaper app in Xamarin (C#).

I decided to write this short “how to”, because there are no such articles at least I didn’t see any at the time of writing this. There are people on sites like Stackoverflow, that ask questions about problems, that they have with their menus, there are few threads on Xamarin forums, some suggestions here and there, but there’s no clear explanation anywhere.

Tools needed: IDE, Xamarin. I used Microsoft Visual Studio, community edition, it already includes Xamarin and is completely free. Nice move, MS.

Disclaimer: please note that I’m not talking about doing this in Java. You need to know C# and what Xamarin is.

So let’s say you have a working wallpaper app for Android and you want it to have settings. Naturally, you add an xml file, name it something like “mysettings.xml”, it’s contents should be like this:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android = "">
        android:defaultValue="true" />

It’s the markup of your settings screen, more on available elements and settings design can be found in official documentation, I’m using this simple markup to illustrate the process.

Next, you need to add an Activity to your project, name it something like “Settings” or w/e you like. Xamarin doesn’t allow direct messing with the manifest, but we can still control it through directives. In our activity code we need to add the following lines before declaring our class:

namespace wallpaperExample
         Name = "com.yourpackage.wallpaperExample.Settings"
         Exported = true)]

It’s important to give it the “Exported” flag, because otherwise the wallpaper won’t be able to show this activity and you’ll get an error. Also the “Name” here consists of your package name – can be anything, then the namespace, then the name of your class (in our case it’s the “Settings”). It’s important not to mess this up, because if you do, then you’ll get an error when pressing “Settings” button in wallpaper picker saying something like “The application is not installed”.

Last thing to do is to add the “Settings” button itself, in your whateverwp.xml add the following line:

android:settingsActivity = "com.yourpackage.wallpaperExample.Settings"

And we’re done. You should obviously use proper naming and apply all this to your own project, I’m just using generic/whatever names as an example.

  • Robert

    OMG. I’ve spent 2 hours on google trying to figure this out. Finally I came across your website and found the solution. I took it step by step and it worked the first try. I seriously spent all night trying to figure out how to get my settings working. THANK YOU SOOO MUCH.

    • Galloper

      Glad I could help 🙂