string.xml内でフォーマットされた html を使用しようとしています。したがって、strings.xmlには次のようなものがあります。
<string name="application_start_message" formatted="false">
<![CDATA[ bla bla bla %1$ bla bla bla %1$.... ]]>
<string name="application_website_url">website.com</string>
そして後でコードで私は:
String string = getString(
R.string.application_start_message,
getString(R.string.application_website_url)
);
私が取得している実行時例外は次のとおりです。
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.artigile.checkmyphone/
com.artigile.checkmyphone.MainActivity}:
java.util.UnknownFormatConversionException: Conversion: <
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.util.UnknownFormatConversionException: Conversion: <
at java.util.Formatter$FormatToken.unknownFormatConversionException(Formatter.java:1399)
at java.util.Formatter$FormatToken.checkFlags(Formatter.java:1336)
at java.util.Formatter.transform(Formatter.java:1442)
at java.util.Formatter.doFormat(Formatter.java:1081)
at java.util.Formatter.format(Formatter.java:1042)
at java.util.Formatter.format(Formatter.java:1011)
at java.lang.String.format(String.java:1988)
at android.content.res.Resources.getString(Resources.java:354)
at android.content.Context.getString(Context.java:347)
at com.artigile.checkmyphone.MainActivity.buildModalStartWarningWindow(MainActivity.java:280)
at com.artigile.checkmyphone.MainActivity.onStart(MainActivity.java:116)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5143)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
... 11 more
これを回避する方法はありますか?