bradford bio photo

Twitter LinkedIn Github Stackoverflow

I’ve been working on a weird exception for the past couple hours and finally figured it out. Since I couldn’t find any information about this exception I figured I’d post about it.  

It happens in my SettingsActivity, which extends SherlockPreferenceActivity. The cause is my string-array of values that have a percent sign in them, and when I set the preference summary that has a percent sign, the OS tries to format that percent sign. There are a few ways to escape the percent signs, but none of them worked. If I used 2 %% signs, it set the summary without an exception, but it showed up as “%%” in the select list. None of the HTML encodings worked either. I even tried to HTML encode the whole string when I set the summary, but I don’t think there is a way to escape the % sign unless you escape it with another %, and that just shows up as “%%” which is unacceptable in my application. So, for now, it will just be “percent”. Lame.

Stack Trace:

FATAL EXCEPTION: main
java.util.UnknownFormatConversionException: Conversion: 
 at java.util.Formatter$FormatSpecifierParser.unknownFormatConversionException(Formatter.java:2304)
 at java.util.Formatter$FormatSpecifierParser.advance(Formatter.java:2298)
 at java.util.Formatter$FormatSpecifierParser.parseConversionType(Formatter.java:2377)
 at java.util.Formatter$FormatSpecifierParser.parseArgumentIndexAndFlags(Formatter.java:2348)
 at java.util.Formatter$FormatSpecifierParser.parseFormatToken(Formatter.java:2281)
 at java.util.Formatter.doFormat(Formatter.java:1069)
 at java.util.Formatter.format(Formatter.java:1040)
 at java.util.Formatter.format(Formatter.java:1009)
 at java.lang.String.format(String.java:1998)
 at java.lang.String.format(String.java:1972)
 at android.preference.ListPreference.getSummary(ListPreference.java:152)