I’m developing an Android app which is a quiz. On the other hand, I’m developing a desktop tool that is based entirely on Swing. The desktop tool is used to inserts the quiz’s questions and produces a serialized object file which contains all the questions on it. I used java.awt.Image to hold an image that is attached with a question.
Unfortunately, when I’ve finished developing the desktop tool and go to the Android side, I figured out that Android has no java.awt.Image. So my question is, is there anyway to include the java.awt.Image within the Android app? or is there another class available in both Java and Android that deals with Image, besides supporting the Swing components? or at least, is there an alternative to solve the problem I’ve faced?
Notes: You may wonder why I’m serializing the object and not just fetching the questions from XML or database. That’s because, I have a need to have a tree data structure as categories of the questions; each category has list of questions beside a sub-category.
Here is the solution: Use
BufferedImageon Java side and convert it to byte array, then on the Android side, get the byte array and convert it toBitmap.Java side:
Android side: