【问题标题】:How to Open a Specific Folder in Phone Gallery?如何在电话库中打开特定文件夹?
【发布时间】:2017-03-22 10:38:02
【问题描述】:

我有一个使用相机的应用程序

1) 在该应用程序中,当用户打开图库时,我正在传递打开默认手机图库的意图,但我希望它只打开特定文件夹??

我怎样才能做到这一点

Intent pickPhoto = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

startActivityForResult(pickPhoto, PICK_PICTURE_SECOND_IMAGE);

2) 我想压缩从图库中选择的图像??

private void SaveImage(Bitmap finalBitmap) {
        String root = Environment.getExternalStorageDirectory().toString();
        File myDir = new File(root + "/saved_images");
        myDir.mkdirs();
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        fname = "Image-" + timeStamp + ".jpg";
        File file = new File(myDir, fname);
        if (file.exists()) file.delete();
        try {
            FileOutputStream out = new FileOutputStream(file);
            finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
            out.flush();
            out.close();
//            textview_imagename1.setText(fname);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

提前致谢!!!

【问题讨论】:

    标签: android android-camera-intent


    【解决方案1】:
     public void showFileChooser() {
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
    }
    

    【讨论】:

      猜你喜欢
      • 2013-05-06
      • 1970-01-01
      • 2021-03-08
      • 1970-01-01
      • 2011-04-06
      • 2019-01-17
      • 1970-01-01
      • 1970-01-01
      • 2019-01-31
      相关资源
      最近更新 更多