Android 当用户选择gallery选项时如何显示所有照片文件夹

Android 当用户选择gallery选项时如何显示所有照片文件夹,android,android-camera,Android,Android Camera,当用户在android中选择gallery选项时,如何显示所有照片文件夹这里是自定义对话框的完整代码和选择图像 btnSelect=(Button)findViewById(R.id.btnselect); btnSelect.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //custom dialogBox

当用户在android中选择gallery选项时,如何显示所有照片文件夹这里是自定义对话框的完整代码和选择图像

btnSelect=(Button)findViewById(R.id.btnselect);

btnSelect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //custom dialogBox
            final Dialog dialog=new Dialog(MainActivity.this);
            dialog.setContentView(R.layout.custom_dialog_layout);
            dialog.setTitle("Select from..");

            //set the custom dialog components
            TextView txtmsg=(TextView)dialog.findViewById(R.id.txtmsg);
          Button btnGallaery=(Button)dialog.findViewById(R.id.btngallery);
            Button btnCamara=(Button)dialog.findViewById(R.id.btncamara);

            btnGallaery.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent image=new Intent();
                    image.setType("image/*");
                    image.setAction(Intent.ACTION_GET_CONTENT);
                       startActivityForResult(Intent.createChooser(image,"select file"),SELECT_IMAGE);
                    dialog.dismiss();
                }
            });




            btnCamara.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent cam=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

                    cam.putExtra("Image", fileUri);
                    startActivityForResult(cam,REQUEST_CAMERA);
                    dialog.dismiss();



                }
            });

            dialog.show();
        }
    });

    public Uri getOutputMediaFileUri(int type) {
         return Uri.fromFile(getOutputMediaFile(type));
    }

    /*
    * returning image / video
    */
   private static File getOutputMediaFile(int type) {

    File mediaFile;
    if (type == MEDIA_TYPE_IMAGE) {

         mediaFile = new File(Environment.getExternalStorageDirectory() + "/DCIM/", "image" + new Date().getTime() + ".jpg");

    }
    else {
        return null;
    }

    return mediaFile;

}
自定义对话框布局.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="20dp"
    android:text="From where to select Image ? "
    android:textStyle="bold"
    android:textSize="20sp"
    android:textColor="@android:color/holo_blue_dark"
    android:layout_gravity="center"
    android:textAlignment="center"
    android:id="@+id/txtmsg"/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="1">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btngallery"
        android:text="Gallery"
        android:textSize="15sp"
        android:textColor="@android:color/black"
        android:layout_gravity="center"
        android:layout_weight="0.5"
        android:layout_margin="10dp"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/btncamara"
        android:text="camara"
        android:textSize="15sp"
        android:textColor="@android:color/black"
        android:layout_weight="0.5"
        android:layout_margin="10dp"/>

     </LinearLayout>
    </LinearLayout>


Android中的gallery选项在哪里?对于select image,我们将使用camera Intent therelook,默认gallery是第三方应用程序。因此,在该应用程序中,排序选项在不同的分区中以不同的方式给出。因此,如果根据相册或最近或日期显示的所有照片都以排序选项为基础,则可能会被删除。因此,在第三方应用程序中,我们无法进行更改。它因模型而异。