2016-03-07 11:14:13 -08:00
|
|
|
|
page.title=ICU4J Android Framework APIs
|
2016-02-24 17:22:31 -08:00
|
|
|
|
|
|
|
|
|
@jd:body
|
|
|
|
|
|
2016-03-08 22:32:51 -08:00
|
|
|
|
<div id="qv-wrapper">
|
|
|
|
|
<div id="qv">
|
2016-02-24 17:22:31 -08:00
|
|
|
|
<h2>In this document:</h2>
|
|
|
|
|
<ol>
|
|
|
|
|
<li><a href="#relation">Relationship to ICU4J</a></li>
|
|
|
|
|
<li><a href="#migration">Migrating to android.icu APIs from ICU4J </a></li>
|
|
|
|
|
<li><a href="#licence">Licensing</a></li>
|
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
|
|
<h2>See Also</h2>
|
|
|
|
|
<ol>
|
|
|
|
|
<li>
|
|
|
|
|
<a class="external-link" href=
|
|
|
|
|
"http://userguide.icu-project.org">Documentation for ICU4J</a>
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li>
|
|
|
|
|
<a class="external-link" href=
|
|
|
|
|
"http://site.icu-project.org/#TOC-What-is-ICU-">Latest standards supported
|
|
|
|
|
by ICU4J</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ol>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
ICU4J is an open-source, widely used set of Java libraries providing Unicode
|
2016-03-07 22:13:29 -08:00
|
|
|
|
and globalization support for software applications. Android N
|
2016-03-05 14:16:19 -08:00
|
|
|
|
exposes a subset of the ICU4J APIs in the Android framework for app developers
|
|
|
|
|
to use under the {@code android.icu} package. These APIs use
|
|
|
|
|
localization data present on the device. As a result, you can reduce your APK
|
|
|
|
|
footprint by not compiling the ICU4J libraries into your APK; instead, you can
|
|
|
|
|
simply call out to them in the framework. (In this case, you may want to provide
|
|
|
|
|
<a href="{@docRoot}google/play/publishing/multiple-apks.html">multiple versions
|
2016-03-07 22:13:29 -08:00
|
|
|
|
of your APK</a>, so users running versions of Android lower than Android N
|
|
|
|
|
can download a version of the app that contains the ICU4J libraries.)
|
2016-02-24 17:22:31 -08:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
This document begins by providing some basic information on the minimum
|
|
|
|
|
Android API levels required to support these libraries. It then explains what
|
|
|
|
|
you need to know about the Android-specific implementation of ICU4J. Finally,
|
2016-03-05 14:16:19 -08:00
|
|
|
|
it tells you how to use the ICU4J APIs in the Android framework.
|
2016-02-24 17:22:31 -08:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<h2 id="relation">Relationship to ICU4J</h2>
|
|
|
|
|
|
|
|
|
|
<p>
|
2016-03-07 22:13:29 -08:00
|
|
|
|
Android N exposes a subset of the ICU4J APIs via the
|
2016-03-07 11:14:13 -08:00
|
|
|
|
<code>android.icu</code> package, rather than <code>com.ibm.icu</code>. The
|
|
|
|
|
Android framework may choose not to
|
2016-03-07 22:13:29 -08:00
|
|
|
|
expose ICU4J APIs for various reasons; for example, Android N does not expose
|
2016-02-24 17:22:31 -08:00
|
|
|
|
some deprecated APIs or those that the ICU team have not yet declared as
|
2016-03-05 14:16:19 -08:00
|
|
|
|
stable. As the ICU team deprecates APIs in the future, Android will also mark
|
2016-02-24 17:22:31 -08:00
|
|
|
|
them as deprecated but will continue to include them.
|
|
|
|
|
</p>
|
|
|
|
|
|
2016-03-05 14:16:19 -08:00
|
|
|
|
<p class="table-caption"><strong>Table 1.</strong> ICU and CLDR versions used
|
2016-03-07 22:13:29 -08:00
|
|
|
|
in Android N.</p>
|
2016-02-24 17:22:31 -08:00
|
|
|
|
<table>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Android API level</th>
|
|
|
|
|
<th>ICU version</th>
|
|
|
|
|
<th>CLDR version</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2016-03-07 22:13:29 -08:00
|
|
|
|
<td>Android N</td>
|
2016-02-24 17:22:31 -08:00
|
|
|
|
<td>56</td>
|
|
|
|
|
<td>28</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
<p>Here are a few important things to note:</p>
|
|
|
|
|
|
|
|
|
|
<ul>
|
2016-03-07 11:14:13 -08:00
|
|
|
|
<li>The ICU4J Android framework APIs do not include all the ICU4J APIs.</li>
|
2016-03-05 14:16:19 -08:00
|
|
|
|
<li>NDK developers should know that Android ICU4C is not supported.</li>
|
|
|
|
|
<li>The APIs in the Android framework do not replace Android’s support for
|
|
|
|
|
<a href="{@docRoot}guide/topics/resources/localization.html">localizing with
|
|
|
|
|
resources</a>.</li>
|
2016-02-24 17:22:31 -08:00
|
|
|
|
</ul>
|
|
|
|
|
|
2016-03-05 14:16:19 -08:00
|
|
|
|
<h2 id="migration">Migrating to the android.icu package from com.ibm.icu</h2>
|
2016-02-24 17:22:31 -08:00
|
|
|
|
|
|
|
|
|
<p>
|
2016-03-05 14:16:19 -08:00
|
|
|
|
If you are already using the ICU4J APIs in your app, and the
|
2016-02-24 17:22:31 -08:00
|
|
|
|
<code>android.icu</code> APIs meet your requirements, then migrating to
|
2016-03-05 14:16:19 -08:00
|
|
|
|
the framework APIs requires you to change your Java imports
|
|
|
|
|
from <code>com.ibm.icu</code> to <code>android.icu</code>. You may then
|
2016-02-24 17:22:31 -08:00
|
|
|
|
remove your own copy of ICU4J files from the APK.
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<p class="note">
|
2016-03-07 11:14:13 -08:00
|
|
|
|
<b>Note</b>: The ICU4J framework APIs use the {@code android.icu}
|
2016-03-05 14:16:19 -08:00
|
|
|
|
namespace instead of {@code com.ibm.icu}. This is to avoid namespace
|
|
|
|
|
conflicts in APKs that contain their own {@code com.ibm.icu} libraries.
|
2016-02-24 17:22:31 -08:00
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<h3 id="migrate-from-android">
|
|
|
|
|
Migrating to android.icu APIs from other Android SDK APIs
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
Some classes in the <code>java</code> and<code>android</code> packages have
|
2016-03-05 14:16:19 -08:00
|
|
|
|
equivalents to those found in ICU4J. However, ICU4J often provides broader
|
|
|
|
|
support for standards and languages.
|
2016-02-24 17:22:31 -08:00
|
|
|
|
</p>
|
|
|
|
|
<p>Here are some examples to get you started:</p>
|
|
|
|
|
<table>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>Class</th>
|
|
|
|
|
<th>Alternatives</th>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><code>java.lang.Character</code> </td>
|
|
|
|
|
<td><code>android.icu.lang.UCharacter</code> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><code>java.text.BreakIterator</code> </td>
|
|
|
|
|
<td><code>android.icu.text.BreakIterator</code> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><code>java.text.DecimalFormat</code> </td>
|
|
|
|
|
<td><code>android.icu.text.DecimalFormat</code> </td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><code>java.util.Calendar</code></td>
|
|
|
|
|
<td>
|
|
|
|
|
<code>android.icu.util.Calendar</code></td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><code>android.text.BidiFormatter</code>
|
|
|
|
|
</td>
|
|
|
|
|
<td><code>android.icu.text.Bidi</code>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><code>android.text.format.DateFormat</code>
|
|
|
|
|
</td>
|
|
|
|
|
<td><code>android.icu.text.DateFormat</code>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td><code>android.text.format.DateUtils</code> </td>
|
|
|
|
|
<td><code>android.icu.text.DateFormat</code>
|
|
|
|
|
<code>android.icu.text.RelativeDateTimeFormatter</code>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
<h2 id="licence">Licensing</h2>
|
|
|
|
|
|
|
|
|
|
<p>
|
2016-03-05 14:16:19 -08:00
|
|
|
|
ICU4J is released under the ICU license. For details, see the <a class=
|
|
|
|
|
"external-link" href=
|
|
|
|
|
"http://userguide.icu-project.org/icufaq#TOC-How-is-the-ICU-licensed-">ICU
|
|
|
|
|
User Guide.</a>
|
2016-02-24 17:22:31 -08:00
|
|
|
|
</p>
|