icu4j太大了,有什么选择吗? [英] icu4j is too big, any alternative?

查看:2048
本文介绍了icu4j太大了,有什么选择吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Android代码中使用icu4j。 jar约为10MB,这使我的整个应用程序注册了15MB的apk。当然,15MB可能是由于Proguard帮助减小了尺寸。无论如何,有没有人知道icu4j的一个较小的替代品?我将icu4j与 libphonenumber 结合使用仅用于一个目的,详细信息这里,我在下面重现:

I am using icu4j in my android code. The jar is about 10MB, which causes my entire application to register an apk of 15MB. Of course the 15MB is likely due to Proguard helping reducing the size. Anyway, does anyone know of a smaller alternative to icu4j? I am using icu4j in conjunction with libphonenumber for one purpose only, which is detailed here, and which I reproduce below:


你需要:

You need:


  • getSupportedRegions()获取地区代码列表

  • getSupportedRegions() to get the list of region codes

getCountryCodeForRegion(regionCode)获取每个国家/地区的国家/地区呼叫代码(1,44等)

getCountryCodeForRegion(regionCode) to get the country calling code for each one (1, 44 etc)

然后要获得实际名称,您应该使用ICU4J - >
http:// icu-project。 org / apiref / icu4j / - >它会以这些区域代码以您的用户所说的任何语言为您提供国家名称

(getDisplayCountry())

And then to get the actual names, you should use ICU4J -> http://icu-project.org/apiref/icu4j/ --> it will get you country names from these region codes in whatever language your user speaks. (getDisplayCountry())


推荐答案

自Android 7.0起(API 24) ,ICU框架已公开,因此您无需在应用程序中单独包含该库。如果您需要,文档建议您创建APK的多个版本将它包含在早期的Android版本中。

As of Android 7.0 (API 24), the ICU framework is exposed so that you don't need to include the library separately in your app. The documentation recommends creating multiple versions of your APK if you need to include it in earlier Android versions.

当然,如果你只需要一件小东西,那么最好找一个可以完成这项工作的原生Android或Java API,或者更小一些第三方库。

Of course, if you only need it for one small thing, then it would be better to find a native Android or Java API that can do the job, or some smaller third-party library.

注意


  • 通过一些工作,可以将ICU库编辑得更小。有关详细信息,请参见此页

  • With some work it may be possible to edit the ICU library to be significantly smaller. See this page for more details.

这篇关于icu4j太大了,有什么选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆