[英]Show image gallery in camera intent
I'm working on a feature where the user can take a picture and choose from the gallery. 我正在开发一项功能,用户可以拍照并从图库中选择。 This is basically where it starts and goes on to save the images in db.
基本上是从这里开始,然后继续将图像保存在db中。
private void showPictureDialog(){
AlertDialog.Builder pictureDialog = new AlertDialog.Builder(this);
pictureDialog.setTitle("Select Action");
String[] pictureDialogItems = {
"Select photo from gallery",
"Capture photo from camera" };
pictureDialog.setItems(pictureDialogItems,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
choosePhotoFromGallary();
break;
case 1:
takePhotoFromCamera();
break;
}
}
});
pictureDialog.show();
}
However, I want to make the user experience better. 但是,我想使用户体验更好。 I want to skip the dialog where the user selects one of the options (from gallery or camera) and instead show the gallery in camera intent.
我想跳过对话框,用户在其中选择选项(从图库或摄影机中选择)之一,而是以摄影机意图显示图库。 Something similar to this:
类似于以下内容:
I hope you get my point. 希望你明白我的意思。 Thanks :)
谢谢 :)
public List<File> getAllShownImagesPath(Context context) { //get all images String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATE_ADDED, MediaStore.Images.Media.SIZE}; List<File> result = new ArrayList<>(); File f = null; final Cursor cursor = context.getContentResolver(). query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, // Specify the provider columns, // The columns we're interested in null, // A WHERE-filter query null, // The arguments for the filter-query MediaStore.Images.Media.DATE_ADDED + " DESC" ); if (cursor != null) { cursor.moveToFirst(); for (int r = 0; r < cursor.getCount(); r++, cursor.moveToNext()) { int i = cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Images.Media.SIZE)); //int l = cursor.getString(1).length(); final int image_path_col = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); if (i > 0) { f = new File(cursor.getString(image_path_col)); if (f.length() > 0) { result.add(f); } } } cursor.close(); } return result; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.