2

我想从默认图库中选择文件,即图像、视频……但是当我使用以下功能打开图库时,它也为我提供了一些不必要的文件选择选项,例如“文件管理器,OI 文件管理器”。这些应用程序安装在我的手机上,当我打开并选择媒体文件时我不想要这些应用程序。

请帮助

Intent intent = new Intent(Intent.ACTION_PICK);
      intent.setType("video/*, images/*");
     intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
      intent.setAction(Intent.ACTION_GET_CONTENT);
       tartActivityForResult(Intent.createChooser(intent, "Select File"),
                        REQUEST_CODE);
4

2 回答 2

1

用这个

Intent intentGallery = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intentGallery, 1);
于 2013-05-30T16:27:39.003 回答
0
public void openGallery(int SELECT_FILE1) {

    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(
            Intent.createChooser(intent, "Select file to upload "),
            SELECT_FILE1);

}

    // gallery................//
protected void onActivityResult(int requestCode, int resultCode,
        Intent imageReturnedIntent) {
    super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
    Uri selectedImageUri = null;
    String filePath = null;
    switch (requestCode) {
    case SELECT_FILE1:
        if (resultCode == Activity.RESULT_OK) {
            selectedImage = imageReturnedIntent.getData();

            if (requestCode == SELECT_FILE1) {
                selectedPath1 = getPath(selectedImage);
                //mimagepath.setText(selectedPath1);


            if (selectedPath1 != null) {












            }


            }
        }

        break;


    }

}
于 2013-05-30T16:45:07.790 回答