java - Executing SAME program on both Android and JVM using different libraries -
java - Executing SAME program on both Android and JVM using different libraries -
my code needs migrate between linux machine , android mobile. basic image processing , uses imageio on linux , bitmapfactory on android load jpeg images. so, observe environment , phone call appropriate methods below:
if (isdalvik()) { bitmap bi = bitmapfactory.decodestream(this.getclass().getresourceasstream("test.jpg")); this.findfaces_android(bi, 1, 40, new file("result.jpg")); } else { bufferedimage bi = imageio.read(exp_starter.class.getresourceasstream("test.jpg")); this.findfaces_j2se(bi, 1, 40, new file("result.jpg")); }
this works fine on linux have placed android.jar in class path. however, fails work on android. when started, claims not finding bufferedimage , imageio classes, although never called else statement not executed.
i tried create empty classes of java.awt.image.bufferedimage , javax.imageio.imageio android application compiler not allow overwriting them.
any thought how prepare problem , making same programme work on both different environments?
apparently, moving code different runtime environment different classes solves problem. here's worked me:
if (isdalvik()) { find_faces_android ff = new find_faces_android(); ff.readimage(this.getclass().getresourceasstream("test.jpg")); int no_detected_faces = ff.findfaces( 1, 40, new file("result.jpg")); } else { find_faces_jvm ff = new find_faces_jvm(); ff.readimage(this.getclass().getresourceasstream("test.jpg")); int no_detected_faces = ff.findfaces( 1, 40, new file("result.jpg")); }
java android cross-platform
Comments
Post a Comment