开发者

import .java file from /assets folder of android project?

开发者 https://www.devze.com 2023-03-26 22:46 出处:网络
I have an SHA1.java file sitting in my assets folder of my android project. My question is how do I access the 开发者_StackOverflow中文版class of that file in my main java file. Is there a way to do s

I have an SHA1.java file sitting in my assets folder of my android project. My question is how do I access the 开发者_StackOverflow中文版class of that file in my main java file. Is there a way to do such a thing?


First of all, you need a .class file to load i

Second of all, you can probably create your own ClassLoader and invoke defineClass() from it::

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/ClassLoader.html#defineClass(java.lang.String, byte[], int, int)

You should then do classObj.newInstance() and handle it.

Also, it may make sense to add some wrapper that makes it easy to call SHA1.class - i.e. a single method that performs everything, since you won't be able to access it without reflection.

0

精彩评论

暂无评论...
验证码 换一张
取 消