为图像和视频调用android画廊

时间:2011-08-03 07:50:02

标签: android

当我必须获得一些图像或视频时

我确实喜欢这个

 Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("video/*");
    startActivityForResult(intent ,  ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD);

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD);

我试着

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

但发生错误

我怎样才能解决这个问题..

感谢您的回复

5 个答案:

答案 0 :(得分:9)

试试这个

final Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/* video/*");
startActivityForResult(galleryIntent, REQUEST_CODE);

答案 1 :(得分:0)

你试过

吗?
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("media/*");
    startActivityForResult(intent , ActNetwork.EXTRA_FLAG_SEARCH_LOCAL_VOD);

答案 2 :(得分:0)

试试这个

intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 1);

适用于2.1

答案 3 :(得分:0)

我也有同样的问题,我找到了解决方案。

Intent pickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
pickerIntent.setType("image/*, video/*");
pickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"});
startActivityForResult(pickerIntent, REQUEST_CODE_FOR_MEDIA);

这里的关键是pickerIntent.putExtra(Intent.EXTRA_MIME_TYPES,new String [] {" image / *"," video / *"});

答案 4 :(得分:0)

  Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
        photoPickerIntent.setType("*/*");
        photoPickerIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "video/* images/*"});
        startActivityForResult(photoPickerIntent, REQUEST_GALLERY);