从android studio上的库中上传图片

时间:2017-02-27 16:11:35

标签: android gallery

我正在尝试从图库上传图片并将其显示在图片视图中但我收到此错误

I/System.out: resolveUri failed on bad bitmap uri: content://media/external/images/media/35

我的代码:

 public void btimage(View view)
    {

        Intent i = new Intent(
                Intent.ACTION_PICK,
                MediaStore.Images.Media.INTERNAL_CONTENT_URI);

        startActivityForResult(i, 100);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);

        if(requestCode==100 && resultCode==RESULT_OK)
        {
            Uri uri= data.getData();
            imgView.setImageURI(uri);

        }
    }

1 个答案:

答案 0 :(得分:0)

试试这个

android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI

代表

MediaStore.Images.Media.INTERNAL_CONTENT_URI