B4J Question javaobject not matched

xulihang

Active Member
Licensed User
Longtime User
Hi guys,

I am new to javaobject. I have trouble accessing the pinyin4j library using javaobject. The code I write is like this:

B4X:
#AdditionalJar: pinyin4j-2.5.0
......
Dim jo As JavaObject
jo.InitializeStatic("net.sourceforge.pinyin4j.PinyinHelper").RunMethod("toHanyuPinyinStringArray",Array As Object("你"))

and I get this wrong message:

B4X:
java.lang.RuntimeException: Method: toHanyuPinyinString not matched.


What should I do to solve this problem?

Thanks.
 

xulihang

Active Member
Licensed User
Longtime User
I figured this out. The parameter's type should be char.

B4X:
Dim singlechar As Char
singlechar="你"
Dim jo As JavaObject
Dim strArray() As String
strArray=jo.InitializeStatic("net.sourceforge.pinyin4j.PinyinHelper").RunMethod("toHanyuPinyinStringArray",Array As Object(singlechar))
For Each pinyin As String In strArray
    Log(pinyin)
Next
 
Upvote 0

moster67

Expert
Licensed User
Longtime User

Attachments

  • b4jpinyin.zip
    932 bytes · Views: 204
Upvote 0

xulihang

Active Member
Licensed User
Longtime User
Upvote 0
Top