当前位置:编程学习 > wap >>

pinyin4j在android的应用问题

本人在eclipse新建工程,导入pinyin4j 运行自写程序,可以正确将汉字转为拼音。但是当我把这个jar包放在系统自带的Contracts中,并配置好android.mk文件后,运行mm 命令后,编译正常,但却无任何效果。
转换方法如下:
public static String getPinYin(String inputString) {  
          
        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();  
        format.setCaseType(HanyuPinyinCaseType.LOWERCASE);  
        format.setToneType(HanyuPinyinToneType.WITH_TONE_MARK);  
        format.setVCharType(HanyuPinyinVCharType.WITH_U_UNICODE);  
  
        char[] input = inputString.trim().toCharArray();  
        StringBuffer output = new StringBuffer("");  
  
        try {  
            for (int i = 0; i < input.length; i++) {  
                if (Character.toString(input[i]).matches("[\u4E00-\u9FA5]+")) {  
                    String[] temp = PinyinHelper.toHanyuPinyinStringArray(input[i], format);  
                    output.append(temp[0]);  
                    output.append(" ");  
                } else  
                    output.append(Character.toString(input[i]));  
            }  
        } catch (BadHanyuPinyinOutputFormatCombination e) {  
            e.printStackTrace();  
        }  
        return output.toString();  
    }  
mk文件如下:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := user

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_STATIC_JAVA_LIBRARIES := pinyinlib googlelogin-client

LOCAL_PACKAGE_NAME := Contacts
LOCAL_CERTIFICATE := shared

include $(BUILD_PACKAGE)

include ${CLEAR_VARS}
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := pinyinlib:pinyin4j-2.5.0.jar
include $(BUILD_MULTI_PREBUILT)
# Use the folloing include to make our test apk.
include $(call all-makefiles-under,$(LOCAL_PATH)) --------------------编程问答-------------------- 楼主解决了吗?也遇到一样的问题.
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,