https://sourceforge.net/projects/pinyin4j 开源协议: GNU General Public License version 2.0 (GPLv2) 仅使用该库, 并未对该库做任何修改.

1. 基本使用

  1. implementation 'me.luzhuo.android:library_pinyin:1.0.12'
  1. String[] datas = new String[]{"中国", "China", "1中国", "↑中国", "中sa↑sa国"};
  2. for (String data : datas) {
  3. String initial = PinYinUtils.getInitialPinyin(data);
  4. Log.e(TAG, "" + initial); // Z C 1 ↑ Z
  5. }

2. 混淆 (proguard-rules.pro)

  1. # ///////////////////// pinyin /////////////////////
  2. -keep class net.sourceforge.pinyin4j.ResourceHelper {*;}