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