Android header preferences on small screen / phone

Short version: If your android preference headers are displaying on a small screen, but not opening the associated preference fragment when clicked, make sure you don’t have launchMode attribute set on your preferences activity in your AndroidManifest.xml file.

Long version: The concept of two-pane preferences of course applies to large screen (tablet) devices, where the left hand-side is a list of ‘headers’ and the right hand side is an associated preference fragment. Google’s built-in template for ‘SettingsActivity’ shows how this can be implemented such that when the activity is displayed on a small screen (e.g. phone) the preference headers are not displayed and instead all preferences are shown on the one screen, separated by categories. To do this they force you to use a deprecated API, which is pretty ugly. Additionally, this only makes sense when you don’t have many preferences. Once you have a large number of preferences, it may make sense to use headers on a small screen, which was the case for me, however it wasn’t working. The headers were displaying fine, but whenever I tapped one, nothing would happen, the onCreate() method of the associated fragment would not be called. By trial and error I finally found that I had


in my manifest file. As soon as I removed that attribute, preference headers worked on a small screen fine.