I am using Bitmap to reduce image size but unfortunately image rotate +90 degrees after uploading to Firebase Storage.
imageUploadActivity.java
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 123 && resultCode== RESULT_OK && data!=null) {
Uri imageUri = data.getData();
Bitmap bmp = null;
try {
bmp = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG, 35, baos);
byte[] datasa = baos.toByteArray();
StorageReference filePath = UserProfilePics.child(UserID + ".jpg");
filePath.putBytes(datasa).addOnCompleteListener(new OnCompleteListener<UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()) {
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
//inflate view
View custom_view = getLayoutInflater().inflate(R.layout.toast_icon_text, null);
((TextView) custom_view.findViewById(R.id.message)).setText("Profile image updated successfully");
((ImageView) custom_view.findViewById(R.id.icon)).setImageResource(R.drawable.ic_baseline_done_24);
((CardView) custom_view.findViewById(R.id.parent_view)).setCardBackgroundColor(getResources().getColor(R.color.green_500));
toast.setView(custom_view);
toast.show();
}
}
}