sorry for asking silly question.but it solved yet my me.please help i had tried all codes on stackoverflow and follow other tutorial but it wont help at all.i am taking imag
You can use following code:
public static String encodeTobase64(Bitmap image) {
Bitmap immagex=image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);
Log.e("LOOK", imageEncoded);
return imageEncoded;
}
Use below code in onActivityResult()
InputStream imageStream = null;
try {
imageStream = this.getContentResolver().openInputStream(selectedImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream);
encodeTobase64(yourSelectedImage);