• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.title=ICU4J Android Framework APIs
2page.image=images/cards/card-nyc_2x.jpg
3
4@jd:body
5
6<div id="qv-wrapper">
7<div id="qv">
8<h2>In this document:</h2>
9<ol>
10    <li><a href="#relation">Relationship to ICU4J</a></li>
11    <li><a href="#migration">Migrating to android.icu APIs from ICU4J </a></li>
12    <li><a href="#licence">Licensing</a></li>
13</ol>
14
15<h2>See Also</h2>
16<ol>
17  <li>
18    <a class="external-link" href=
19    "http://userguide.icu-project.org">Documentation for ICU4J</a>
20  </li>
21
22  <li>
23    <a class="external-link" href=
24    "http://site.icu-project.org/#TOC-What-is-ICU-">Latest standards supported
25    by ICU4J</a>
26  </li>
27</ol>
28</div>
29</div>
30
31<p>
32  ICU4J is an open-source, widely used set of Java libraries providing Unicode
33  and globalization support for software applications. Android N
34  exposes a subset of the ICU4J APIs in the Android framework for app developers
35  to use under the {@code android.icu} package. These APIs use
36  localization data present on the device. As a result, you can reduce your APK
37  footprint by not compiling the ICU4J libraries into your APK; instead, you can
38  simply call out to them in the framework. (In this case, you may want to provide
39  <a href="{@docRoot}google/play/publishing/multiple-apks.html">multiple versions
40  of your APK</a>, so users running versions of Android lower than Android N
41  can download a version of the app that contains the ICU4J libraries.)
42</p>
43
44<p>
45  This document begins by providing some basic information on the minimum
46  Android API levels required to support these libraries. It then explains what
47  you need to know about the Android-specific implementation of ICU4J. Finally,
48  it tells you how to use the ICU4J APIs in the Android framework.
49</p>
50
51<h2 id="relation">Relationship to ICU4J</h2>
52
53<p>
54  Android N exposes a subset of the ICU4J APIs via the
55  <code>android.icu</code> package, rather than <code>com.ibm.icu</code>. The
56  Android framework may choose not to
57  expose ICU4J APIs for various reasons; for example, Android N does not expose
58  some deprecated APIs or those that the ICU team have not yet declared as
59  stable. As the ICU team deprecates APIs in the future, Android will also mark
60  them as deprecated but will continue to include them.
61</p>
62
63<p class="table-caption"><strong>Table 1.</strong> ICU and CLDR versions used
64  in Android N.</p>
65<table>
66<tr>
67<th>Android API level</th>
68<th>ICU version</th>
69<th>CLDR version</th>
70</tr>
71<tr>
72<td>Android N</td>
73<td>56</td>
74<td>28</td>
75</tr>
76</table>
77
78<p>Here are a few important things to note:</p>
79
80<ul>
81<li>The ICU4J Android framework APIs do not include all the ICU4J APIs.</li>
82<li>NDK developers should know that Android ICU4C is not supported.</li>
83<li>The APIs in the Android framework do not replace Android’s support for
84<a href="{@docRoot}guide/topics/resources/localization.html">localizing with
85resources</a>.</li>
86</ul>
87
88<h2 id="migration">Migrating to the android.icu package from com.ibm.icu</h2>
89
90<p>
91  If you are already using the ICU4J APIs in your app, and the
92  <code>android.icu</code> APIs meet your requirements, then migrating to
93  the framework APIs requires you to change your Java imports
94  from <code>com.ibm.icu</code> to <code>android.icu</code>. You may then
95  remove your own copy of ICU4J files from the APK.
96</p>
97
98<p class="note">
99  <b>Note</b>: The ICU4J framework APIs use the {@code android.icu}
100  namespace instead of {@code com.ibm.icu}. This is to avoid namespace
101  conflicts in APKs that contain their own {@code com.ibm.icu} libraries.
102</p>
103
104<h3 id="migrate-from-android">
105  Migrating to android.icu APIs from other Android SDK APIs
106</h3>
107
108<p>
109  Some classes in the <code>java</code> and<code>android</code> packages have
110  equivalents to those found in ICU4J. However, ICU4J often provides broader
111  support for standards and languages.
112</p>
113<p>Here are some examples to get you started:</p>
114<table>
115<tr>
116<th>Class</th>
117<th>Alternatives</th>
118</tr>
119<tr>
120<td><code>java.lang.Character</code> </td>
121<td><code>android.icu.lang.UCharacter</code> </td>
122</tr>
123<tr>
124<td><code>java.text.BreakIterator</code> </td>
125<td><code>android.icu.text.BreakIterator</code> </td>
126</tr>
127<tr>
128<td><code>java.text.DecimalFormat</code> </td>
129<td><code>android.icu.text.DecimalFormat</code> </td>
130</tr>
131<tr>
132<td><code>java.util.Calendar</code></td>
133<td>
134<code>android.icu.util.Calendar</code></td>
135</tr>
136<tr>
137<td><code>android.text.BidiFormatter</code>
138 </td>
139<td><code>android.icu.text.Bidi</code>
140 </td>
141</tr>
142<tr>
143<td><code>android.text.format.DateFormat</code>
144 </td>
145<td><code>android.icu.text.DateFormat</code>
146 </td>
147</tr>
148<tr>
149<td><code>android.text.format.DateUtils</code> </td>
150<td><code>android.icu.text.DateFormat</code>
151<code>android.icu.text.RelativeDateTimeFormatter</code>
152</td>
153</tr>
154</table>
155
156<h2 id="licence">Licensing</h2>
157
158<p>
159  ICU4J is released under the ICU license. For details, see the <a class=
160  "external-link" href=
161  "http://userguide.icu-project.org/icufaq#TOC-How-is-the-ICU-licensed-">ICU
162  User Guide.</a>
163</p>
164