Victor
Victor

Reputation: 193

Add images to jar library

I want to add images to a jar-library to prevent that anyone can change it, but i don't know how to do it. Could somebody help me?

Thanks.

Upvotes: 1

Views: 920

Answers (3)

Victor
Victor

Reputation: 193

After looking for some other ways, i test the "base 64 code/decode" and it works really good. Only need do this:

String encodedImage = "encoded string of image";    
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); 

Then only need to setImageBitmap to the ImageView or like you need.

To encode the image i used this:

http://www.motobit.com/util/base64-decoder-encoder.asp

Upvotes: 2

Akshay
Akshay

Reputation: 1137

1)Right click on your project -> Export.

2)Expand java folder and select "Jar File"

3)Click Next. ( a window will open up).

4)Select the classes and the image file you want to export as jar. ( in "select the resources to export" panel )

5) set the export destination and click finish.

Now the jar will have all the classes and the image file you want.

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1006924

Any means of putting an image on a device will allow sufficiently motivated users the ability to change it. Whatever you think "add images to a jar-library" means will not change that.

If you do not want users changing your images, do not put the image on the user's device.

Upvotes: 0

Related Questions