I am trying to get the images from sd card using Intent. Below is my code:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
When I am running my app on samsung it's shows images to select but when I run the same code on Micromax it's showing images as well as videos.
I want to select only images. How can I solve this problem?
I solved this problem by checking the extension of the file I am receiving and if the received file's extension is a video file's extension then I am showing user a Toast to select only photo.
Below is the method I used to get the file's extension
public static String getImageExtensionFromPath(String imagePath) {
String[] imageNameArray = imagePath.split("/");
String imageName = imageNameArray[imageNameArray.length - 1];
String[] imageArray = imageName.split("\\.");
String finalImageName = imageArray[1];
return finalImageName;
}
Add this in your AndroidManifest.xml
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
Add intent-filter into your specific listed activity. check this Google Code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With