are java libraries allowed in android..?
Hi all Stack Overflow members,
I have written native Java code to capture a screen shot of the desktop. It uses the following libraries; are thes开发者_Go百科e libraries allowed in Android? If not, what should I do to take screen shots in Android?
javax.swing.*;
javax.imageio.*;
java.awt.*;
java.awt.event.*;
java.awt.image.*;
java.awt.AWTException;
java.awt.Robot;
java.awt.Rectangle;
java.awt.Toolkit;
java.awt.image.BufferedImage;
No, some of these are not available on android. Swing is not available, for instance.
For a full listing, check the api docs here: http://developer.android.com/reference/packages.html
There's already a question on SO about capturing the screen that you can check out: How to capture the android device screen content?
For java.awt.Rectangle, i'm able to resolve it by clicking on "Fix project setup..." in eclipse error fix suggestion. I think you need to check if Java JDK is in the library of your android project under /libs folder.
Hope it helps.
Basically what android does is it transforms .class files to .dex file. If your jar file (classes) is compatible with Dalvik VM of android, that jar will be supported in android. If not, then you have to take source code of that jar file and replace the classes (with android supported class) which are not compatible to Dalvik VM. It is possible that you wan't find replacement for all classes.
精彩评论