开发者

Picking images and videos on Android on 2.1 using ACTION_GET_CONTENT

I'm working on an app that needs to have the user select an image or video. On pre-2.1 devices, using ACTION_GET_CONTENT seems to work fine with multiple MIME types:

new Intent(Intent.ACTION_GET_CONTENT).setType("video/*, image/*")

However, on a Droid running 2.1, this gives a "There are no items in your collection". Using the same code with either "video/" or "image/" gives t开发者_StackOverflow中文版he desired result. Is there a way to get my 2.1 device to allow the user to select both types of content within a single Intent?


Putting the request into a function and then calling the function with onClick().

public void openGalleryImage(){
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent,"Select Image "),
            SELECT_IMAGE);
}

public void openGalleryVideo(){
    Intent intent = new Intent();
    intent.setType("video/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent,"Select vVideo "), 
            SELECT_VIDEO);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜