Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 220.127.116.11 release ready!
Owner and Founder. Opencart
There are various situations in which you have to give user a facility to select an image from their android devices. For this giving user a File explorer could be a wrong thing, you have to open the gallery so that the user can select an image. Here is the code for this scenario.
Firstly you have to create a button on whose click we will open devices library. But before that you should have a READ_EXTERNAL_STORAGE permission.
Also please remember that from API 23 and above there are Run-time permissions so you have to check for them like I did.
So I am going to have a Button and a EditText. On Buttons click we will open our gallery or any Image Viewer and in the EditText we will set the name of the image we selected.
This line will create a dialog that will ask user for a permission, so we have to handle the user response to the permission as well and also the onActivityResult() method as well after all it will run when you select an image.
And you have the image you wanted. You can load this image by converting it in a Bitmap or anything you want to do with it. For uploading this file to server you can follow this link.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.