import .java file from /assets folder of android project?
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.
精彩评论