![]() ![]() Since I have done all the work writing the function for you, all that's left to do is to extract the imageUrl from the dataSnapshot in onDataChange and use the function I gave you. This can be done with addCompleteListener(task -> Finally, we need to collect the result of the getDownloadUrl() task.We can continue from our previous putStream task using continueWithTask(newtask). While this can be performed by using userStorageRef.getDownloadUrl(), this in itself is an additional side-task that we must perform and request from Firebase Storage. Recall we want to get the download URL for our image as well.This putStream method is a task that executes asynchronously (sepearate from the UI). This can be done using putStream(stream) method. Now that we have a reference to where we want to upload our image, we just need to push the stream that we created in Step 6 to our reference. Warning: Steps 4 to 8 are fairly complex, it's ok if you cant understand getUid () StorageReference userStorageRef = storageRef. getReference () String userId = FirebaseAuth. StorageReference storageRef = FirebaseStorage. To start off, create an onClickistener for each of other ImageViews, by pasting this code in the initialiseWidgetsForPets function. ![]() We will first need to configure our ImageViews in MyPetActivity to open a dialog for us to choose an Image to change to. Let's try to make it such that clicking on the pet images in MyPetActivity triggers a dialog to open an Image Picker. ![]() Set the ImageView to our new downloaded image.Download the new image if any image url is changed.Constantly listen for changes in the Image Url of the pets.Store this Image Url under our user and corresponding pet in Firebase Realtime DatabaseĪt the same time, we will also need our App to:.Retrieve the Image Url of the uploaded image.Using the image selected, upload the image to a predefined location in Firebase Storage.Display an Image Picker when the images in MyPetActivity are clicked.Our overall flow we need to add in the Android App will be to: Implementation ':firebase-storage'Īs usual, remember to press Sync now Overall Flow for our App ¶ ![]() We'll need to add this line of dependency to the module-level adle file, under dependencies: Setting up Firebase Storage on our Android app ¶ This is okay for us since our users need to be authenticated to use the app. Right now, our Firebase Storage only allows Authenticated users to access this storage. After it is done loading, you should see something like this Select asia-southeast2 for the location, and press Done.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |