Android 图像未在移动设备的ImageView中显示,但在AVD中工作

Android 图像未在移动设备的ImageView中显示,但在AVD中工作,android,image,android-intent,Android,Image,Android Intent,我尝试创建一个新的意图来获取图像文件,根据意图的结果,我获得了图像uri并设置为imageView,但这在我的AVD中甚至在Bluestack中都可以正常工作,但在我的手机中不起作用(在转换为apk后安装)。图像选择屏幕出现,但选择图像后,imageView中仅显示空白 这是我点击imgView的代码 imgView.setOnClickListener(new View.OnClickListener() { @Override public void onCl

我尝试创建一个新的意图来获取图像文件,根据意图的结果,我获得了图像uri并设置为imageView,但这在我的AVD中甚至在Bluestack中都可以正常工作,但在我的手机中不起作用(在转换为apk后安装)。图像选择屏幕出现,但选择图像后,imageView中仅显示空白

这是我点击imgView的代码

imgView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent,"Select contact Image"),1);
        }
    });
基于intent方法的结果分析

 public void onActivityResult(int reqCode,int resCode,Intent data)
{
    super.onActivityResult(reqCode,resCode,data);

    if(resCode==RESULT_OK) if (reqCode == 1) {

        imgView.setImageURI(data.getData());
        imgUri = data.getData();
    }

}
注意:我的图像视图是100*100像素的缩放图像视图,请尝试此操作

//this code calls the app or phone to pick an image from the gallery    
    pick = 0;
    Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(i, pick);
在结果的活动中使用此

//process image gotten from gallery
                if (requestCode == pick && resultCode == getApplicationContext().RESULT_OK) {

                    Uri imgUri = data.getData();
Bitmap bitmap = null;

                try {
                    bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imgUri));
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                ImageView.setImageBitmap(bitmap);

}

看起来像是解决问题。您的映像位于何处(路径)?映像的路径是存储/模拟/0/DCIM/Camera/xyz.jpg这也会导致未加载映像。Sry您的代码工作得很好,但我没有包含读取外部存储的权限。