我正在使用共享对话框选择要在本地数据库中上传的映像,但是我无法启动活动以捕获URI链接。
代码如下:
selectImage = (Button) dialog.findViewById(R.id.selectImage);
selectImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//code to fethc the image form the local strorage
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI );
startActivityForResult(i, REQUEST_CODE);
}
});
尝试使用 setType()
添加类型为"图像",因为您想选择image,
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI );
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, "Select Picture"), req_code);
,还检查点击侦听器是否在工作。