仅打开默认图库

时间:2013-05-30 16:21:08

标签: android

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

plz help

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);

2 个答案:

答案 0 :(得分:1)

使用此

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

答案 1 :(得分: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;


    }

}