I have an app where users can register/login and do stuff. The user credentials are stored in a database. I am wondering how can I let the user to upload a profile photo on the app, do I need to send the photo to the database or can I do it locally? Let's say the user chooses a photo and it will be set in an ImageView, how can I make it persistent? How can I load the photo onto the ImageView when the user logs in, do I need to use a database or can I do this locally?
You shouldn't save the profile photo locally. If a user log in on another device, he will need to set another profile pic, and this is so wrong.
You may upload the pic on the server using an api and fetch it when you need to display it. Then you could use a productive tool lib like picasso for caching it locally.
you can do it locally if you don't required online process.
you simply store (in Share Preference) path of the image which user have select and use this path every time user log in
Related
I am trying to create an app using Android Studio. My client wants to create an app for their online medicines website, wherein the user can take a photo of their prescription, the photo will be accessible by the admins and they can use that image to understand what does the user require and deliver those medications at the user's doorsteps.
So can anyone please guide me through with making this page, or maybe share a link where the making of such a page is shown? Would be really helpful, thank you for giving me your time.
There can be several possible approaches for this type of questions/requirements. I am mentioning a few steps to guide you through the process.
You will have to create a webserver, which will be storing the user data (profile, uploaded prescriptions, etc.). The user data (textual) will be stored in the Database, however, the images will be uploaded in a directory over the server, and their corresponding links will be stored in the DB for reference.
There will be a webserver API which will fetch user data (user unique ID) from app and then store it in the DB. The image part can be accepted in several ways: MultiPart, Base64 encoded, Byte Array Converted
All these methods will send the image info from the android app to the webserver, which will follow the logic mentioned in Point 1 and save the image.
The Android app will have an activity where the user will either capture an image of the prescription form, using Camera, or can upload the image (if already captured/downloaded). You will have to learn doing this from similar links as these:
https://developer.android.com/training/camera/photobasics
Dialog to pick image from gallery or from camera
The Android app will send the unique ID of the user, along with the image data, to the Webserver API, which in-turn process as per Point 2.
You can start implementing the process and then can turn up to StackOverflow again for guidance. There are numerous tutorials to implement a similar functionality too.
https://www.simplifiedcoding.net/android-upload-image-to-server/
http://programmerguru.com/android-tutorial/how-to-upload-image-to-php-server/
https://www.codepool.biz/take-a-photo-from-android-camera-and-upload-it-to-a-remote-php-server.html
All the best!
I'm currently working on an Firebase android application, and after doing some research it seems that Firebase doesn't allow apps to display user information other than the logged in user, for security reasons.
I would like to know then what are some secure ways to do so, or how is it usually done, because what is the point of having profile pictures and other information if you can't show them to other users anyway?
For example, should I save a profile picture copy on Firebase Storage for each user? How should I link the actual images to their corresponding user? What about other relevant information about the user, should I create a "User" node in firebase database that somehow links to the original user in "authentication"?
Should I save a profile picture copy on Firebase Storage for each user ? Yes
How should I link the actual images to their corresponding user ? You can create a folder Users and then for each user create a folder with their userid that uniquely identifies each user. In other words, you can create a Firebase storage structure like this :
Users
|_userid
|_picture
Should I create a "User" node in firebase database that somehow links to the original user in "authentication"? Of course if you want to store and get user's information. Just avoid to store passwords and emails.
I would like to know how can I prevent my users from deleting an image from the internal storage (for example, a photo) before it gets uploaded to the server.
I am using Firebase as my backend, and every works fine. But, if the user deletes the image before it can get uploaded (this happens because if there is not the internet I resume the upload once the user phone connects to the internet) my app crash because the route does no exist.
And I know I can check if the file exists, and do something else, but, since people is uploading important information, a placeholder will be not an option.
Thanks in advance for your help.
I have this social shopping application that I am making and it requires users to register and upload a profile picture and other information that is required then I had tried to display static images in my android project but now since i am about to go live.
My problem is how can I let users upload images and also retrieve the uploaded image to be set as a profile picture of the user
I am developing a chatting/messaging app and I want to let the user select an image that they've stored online (i.e. picasa, photobucket, flickr, etc) which will be shown as part of the chat User Interface for anyone that is chatting with the user.
For example:
User_A is messaging/chatting with
User_B.
User_B will see a small thumbnail
image of User_A
User_A will see a small thumbnail of
User_B.
note: my web server is facilitating the text exchange between the two users.
At first I thought I would implement a photo upload function in my app and store the photo's on my server that each client would download. But then I realized that this is just re-inventing the wheel because there are now a lot of online picture sharing services.
So I want my server to simply store the URL of the images that User_A and User_B have selected - my app is notified of the URL's and downloads the pictures.
However, how is this implemented ? (Specifically, the image selection to obtain the URL in a userfriendly manner)
I've visualized the following userfriendly use-case...
user opens the options activity in my
app and pushes the button to select
an image to present in the chat UI.
an intent dialog is shown with all of
the possible image hosting services
installed on the mobile phone
(picasa, photobucket, etc) - but
local storage shall not be shown.
the image picker of the chosen
application is shown and the user
chooses the image.
the image picker closes and returns
the URL to my app.
If this can't be implemented, then my only alternative (that I know of) is to have users copy'n'paste the URL of the image they want to use - which is not userfriendly on mobile devices.
Any help is greatly appreciated.
That doesn't seem very difficult to me.
You can predefine which Image hosting services you wish to use.
Picassa and Flickr have their APIs AFAIK.
Present user with an option to choose from your predefined offerings.
When they choose, present the album of the user.
When the user ends up selecting an image, Image hosting will let you know about their URLs (You can download all images of that album and display them natively in your app, it will fetch information about them, like their URL with them, which will be easy to track)
Get the URL, and update the chat webservice about it.
Create the Chat activity in a way that it polls your webservice after a particular interval to check whether any one of both the users involved in chat have changed their images. If they have, load the new one.
I can detail you on this if you have any doubts.