page.title=ICU4J Android Framework APIs @jd:body

In this document:

  1. Relationship to ICU4J
  2. Migrating to android.icu APIs from ICU4J
  3. Licensing

See Also

  1. Documentation for ICU4J
  2. Latest standards supported by ICU4J

ICU4J is an open-source, widely used set of Java libraries providing Unicode and globalization support for software applications. The N Developer Preview 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 multiple versions of your APK, so users running versions of Android lower than the N Developer Preview can download a version of the app that contains the ICU4J libraries.)

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, it tells you how to use the ICU4J APIs in the Android framework.

Relationship to ICU4J

The Preview exposes a subset of the ICU4J APIs via the android.icu package, rather than com.ibm.icu. The Android framework may choose not to expose ICU4J APIs for various reasons; for example, the N Preview does not expose some deprecated APIs or those that the ICU team have not yet declared as stable. As the ICU team deprecates APIs in the future, Android will also mark them as deprecated but will continue to include them.

Table 1. ICU and CLDR versions used in the Preview.

Android API level ICU version CLDR version
N Developer Preview 56 28

Here are a few important things to note:

Migrating to the android.icu package from com.ibm.icu

If you are already using the ICU4J APIs in your app, and the android.icu APIs meet your requirements, then migrating to the framework APIs requires you to change your Java imports from com.ibm.icu to android.icu. You may then remove your own copy of ICU4J files from the APK.

Note: The ICU4J framework APIs use the {@code android.icu} namespace instead of {@code com.ibm.icu}. This is to avoid namespace conflicts in APKs that contain their own {@code com.ibm.icu} libraries.

Migrating to android.icu APIs from other Android SDK APIs

Some classes in the java andandroid packages have equivalents to those found in ICU4J. However, ICU4J often provides broader support for standards and languages.

Here are some examples to get you started:

Class Alternatives
java.lang.Character android.icu.lang.UCharacter
java.text.BreakIterator android.icu.text.BreakIterator
java.text.DecimalFormat android.icu.text.DecimalFormat
java.util.Calendar android.icu.util.Calendar
android.text.BidiFormatter android.icu.text.Bidi
android.text.format.DateFormat android.icu.text.DateFormat
android.text.format.DateUtils android.icu.text.DateFormat android.icu.text.RelativeDateTimeFormatter

Licensing

ICU4J is released under the ICU license. For details, see the ICU User Guide.