No, I hadn't thought of using "%%". That works, thanks!

FWIW, this is happening in stock Honeycomb, not CM as the OP was
experiencing.

String

On May 20, 6:34 pm, Kostya Vasilyev <[email protected]> wrote:
> Percent character in String.format() is obtained by specifying "%%" (two
> percent signs).
>
> http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter....
>
> ( search for "percent", where it says "The result is a literal '%'" )
>
> But I bet you already knew that :)
>
> On the other hand, this requires that the string pass through Format to
> produce the single percent sign, which it doesn't for stock Android source.
>
> How about you create a subclass of ListPreference, override getSummary,
> and return whatever you need, skipping the call to String.format(),
> effectively undoing the CM change.
>
> As a side note, that's custom firmware for you. Users probably love the
> feature to see the current list entry in every application, but it seems
> so insignificant compared to a possible crash. And no try/catch block in
> the modified version either...
>
> -- Kostya
>
> 20.05.2011 21:15, String пишет:
>
>
>
>
>
>
>
>
>
> > Reviving an old [degenerate] thread, rather than creating a new one...
>
> > I've been getting occasionalUnknownFormatConversionExceptionerror
> > reports in my Dev Console, and had no idea what they were from. Today
> > I think I've figured it out, because it's occurring reliably on my
> > Honeycomb device.
>
> > Turns out it happens when there's a "%" character in a string resource
> > used as a label in a PreferencesActivity. Seems that the system thinks
> > it's going to be a format specifier, tries to evaluate it as such,
> > fails, and then falls over. But in my case, it's not; I'm letting the
> > user specify a pref for transparency of an AppWidget, with options
> > like 25%, 50%, etc.
>
> > I'm not sure how to fix it yet, and I'm open to suggestions. I tried "/
> > %", like you do for an apostrophe char, but that didn't work at all.
> > Tried "&#37;" (the entity for "%"), but apparently that gets evaluated
> > too early, and the same problem occurs. If all else fails, I could
> > just use "percent", but that's kind of hokey.
>
> > Any other ideas?
>
> > String
>
> > On Apr 5, 8:38 am, mastermind<[email protected]>  wrote:
> >> Some error occured on device with Cyanogen:
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105):
> >> java.util.UnknownFormatConversionException: Conversion is ''
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at java.util.Formatter
> >> $FormatSpecifierParser.advance(Formatter.java:2641)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at java.util.Formatter
> >> $FormatSpecifierParser.parseConversionType(Formatter.java:2716)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at java.util.Formatter
> >> $FormatSpecifierParser.parseArgumentIndexAndFlags(Formatter.java:2687)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at java.util.Formatter
> >> $FormatSpecifierParser.parseFormatToken(Formatter.java:2624)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at
> >> java.util.Formatter.doFormat(Formatter.java:1072)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at
> >> java.util.Formatter.format(Formatter.java:994)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at
> >> java.lang.String.format(String.java:2254)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at
> >> java.lang.String.format(String.java:2219)
> >> 04-03 14:35:04.793 E/AndroidRuntime(21105): at
> >> android.preference.ListPreference.getSummary(ListPreference.java)
> >> It happens only on Cyanogen's firmware when there's "%" symbol in
> >> ListPreference's summary.
>
> >> If u will open ListPreference.java from Froyo's sources u wouldn't
> >> find method ListPreference.getSummary, so it looks like ListPreference
> >> uses base method from Preference.java:
> >>   public CharSequence getSummary() {
> >>          return mSummary;
> >>      }
> >> And javadoc's from eclipse it confirms that:Returns the summary of
> >> this Preference.
>
> >> Ok, now let's open ListPreference.java from Cyanogen's sources:
> >>    public CharSequence getSummary() {
> >>          final CharSequence entry = getEntry();
> >>          if (mSummary == null || entry == null) {
> >>              return super.getSummary();
> >>          } else {
> >>              return String.format(mSummary, entry);
> >>          }
> >>      }
> >> It look's like it's Cyanogen's feature (only 8 bug reports from>3000
> >> users), but let's go 
> >> tohttp://developer.android.com/reference/android/preference/ListPrefere...
> >> Returns the summary of this ListPreference. If the summary has a
> >> String formatting marker in it (i.e. "%s" or "%1$s"), then the current
> >> entry value will be substituted in its place.
>
> >> WHAT IS GOING ON HERE???
> >> Can someone explain how *exactly* getSummary works?
>
> --
> Kostya Vasilyev --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to