Over a million developers have joined DZone.

Use BinaryDrawable to Bundle Images into Android JAR Files

DZone's Guide to

Use BinaryDrawable to Bundle Images into Android JAR Files

· Java Zone ·
Free Resource

Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.

Android developers interested in including images in their JAR files - at least those making limited use of images and hoping to avoid the trouble of a res folder or Android library project - might find BinaryDrawable, a new tool from Hipmob, to be useful. According to Hipmob, it works like this:

To convert any image that can be understood by the Android platform's built-in BitmapFactory into a BinaryDrawable instance we simply read the image file and create a Java source file that includes a byte array with the image data. The generated class can then use decodeByteArray to get a Bitmap, and then it is a short hop to a BitmapDrawable.

Be aware, though, that there are some serious limitations to this tool: only very small images will work (under about 10kb), and JPG and PNG are the only acceptable formats. So, BinaryDrawable isn't for everybody, but if you only need small images here and there - icons seem like the most likely use - it could be worth checking out.

Connect any Java based application to your SaaS data.  Over 100+ Java-based data source connectors.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}