我有一个使用相机的应用程序
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();
}
}
提前感谢!!!
答案 0 :(得分:-2)
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);
}