0

The Base64.encode doesn't want to take the argument "image", and I don't know how to figure out. I've never used Base64 before.

Bitmap bm = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri));
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();  
                    bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object   
                    byte[] image = baos.toByteArray();

                    String encodedImage = Base64.encode(image);

Edit: I use an external package of Base64 http://iharder.sourceforge.net/current/java/base64/

1

1 Answer 1

2

Base64 encode takes at least two arguments. Perhaps try Base64.encode(image, Base64.DEFAULT)

Sign up to request clarification or add additional context in comments.

5 Comments

"The method encode(ByteBuffer, ByteBuffer) in the type Base64 is not applicable for the arguments (byte[], String)" I try to convert to ByteBuffer but there is still a problem...It seems pretty simple but I'm stuck like a noob.
There is no method encode(ByteBuffer, ByteBuffer) on android.util.Base64. As you sure you're using the android Base64 implementation?
I downloaded a Base64 package to make an application for all the versions of Android. Android.util.Base64 is available only after 2.2 version of android.
Perhaps you should update your original questions to let people know what Base64 package you're using.
Shame on me, I looked the wrong doc...the answer was encodeBytes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.