Android 如何关闭根据Intent.Action Pick创建的对话框以获取画廊图像?

Android 如何关闭根据Intent.Action Pick创建的对话框以获取画廊图像?,android,android-intent,Android,Android Intent,我正在使用Intent获取画廊图像,这会导致一个对话框来选择一个选项。 我使用这个意图 Intent photoPickerIntent = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(photoP

我正在使用Intent获取画廊图像,这会导致一个对话框来选择一个选项。 我使用这个意图

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

            startActivityForResult(photoPickerIntent, 123);

但是我希望当我在对话框外部触摸时,这个对话框会显示dimiss。另外,我正在使用Fragment

使用这个:
yournameofdialog.setcanceledontouchout(true)

但我认为这不是对话,而是一种新的活动。要取消此操作,请使用设备的“后退”按钮

希望它有帮助

使用它可能会有帮助

Dialogname.setCanceledOnTouchOutside(true);
还是这个

public boolean onTouchEvent(MotionEvent event)  
{


}

使用dialog.disclose();具体要求是什么?我得到了解决方案,在这里无法完成我想要触摸事件而不是反按编辑启动对话框的意图,我不知道对话框的名称
   if(event.getAction() == MotionEvent.ACTION_OUTSIDE){  
    System.out.println("TOuch outside the dialog ******************** ");  
           this.dismiss();  
   }  
   return false;