https://sourceforge.net/projects/pinyin4j 开源协议: GNU General Public License version 2.0 (GPLv2) 仅使用该库, 并未对该库做任何修改.
1. 基本使用
implementation 'me.luzhuo.android:library_pinyin:1.0.12'
String[] datas = new String[]{"中国", "China", "1中国", "↑中国", "中sa↑sa国"};
for (String data : datas) {
String initial = PinYinUtils.getInitialPinyin(data);
Log.e(TAG, "" + initial); // Z C 1 ↑ Z
}
2. 混淆 (proguard-rules.pro)
# ///////////////////// pinyin /////////////////////
-keep class net.sourceforge.pinyin4j.ResourceHelper {*;}