Ad
How To Update Profile Image To Firebase After Select Picture And Crop It?
How can I update my current user profile picture into firebase after I select an image and crop it?
Here is my code:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE && resultCode == RESULT_OK){
Uri imageUri = CropImage.getPickImageResultUri(getActivity(),data);
cropRequest(imageUri);
}
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE){
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK){
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), result.getUri());
imgUserProfile.setImageBitmap(bitmap);
final ProgressDialog pd = new ProgressDialog(getContext());
pd.setMessage("Please wait ");
pd.show();
} catch (IOException e){
e.printStackTrace();
}
}
}
}
How do I continue from there? Any suggestions?
Ad
Answer
There are many options:
- One of the most useful ones I would use would be to upload the picture to
Firebase Storage
. It's really easy to upload it, and whenever your user signs in again you could download the file to local storage for daily usage. - Another option(this is a bit clunky) might be to store the pixel array of the bitmap in a firebase node. It is blazingly fast and you can store it in your firebase database, but also in your shared preferences. By using an additional compression function you could even enhance the function.
I would recommend, however, using firebase storage as it is the one and only secure option. So go for it. For firebase storage take a look at this link it's the documentation(pretty easy to follow):
https://firebase.google.com/docs/storage/android/upload-files
And also here: https://code.tutsplus.com/tutorials/image-upload-to-firebase-in-android-application--cms-29934
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad