android - how to check selected file is an image? -
Friends,
I'm trying to display an image from the gallery, now I want to check That selected file
Users can select video file, image file etc. Anything so I want to allow images only.
Click on the active button Private Zero selectImageFromGallery () {startActivityForResult (new intent (Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), 0); } @ Override Protective Result on Intact Result (Int Requestcode, Int Outcome Results, Intent Data) {Switch (Outcome Code) {Case 0: Logs. I ("Macmine", "User canceled"); break; Case -1: _data = Data; ShowImageInActivity (); break; }}
intent = new intent (int. Action_GET_CONTENT); Intent.setType ("image / *"); StartActivityForResult (intent, IMAGE_PICK);
No need to see if you only want to select images, use the above asset, in the case of audio and video files, it will automatically filter your required files Does.
Comments
Post a Comment