Reputation: 193
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
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
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
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