Image View not set in Android L using Picasso after loading from gallery

久未见 提交于 2019-12-08 09:40:00

问题


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode==RESULT_LOAD_IMAGE && resultCode==RESULT_OK && data!=null)
    {
        Uri selectedImage = data.getData();

        String [] filePath = {MediaStore.Images.Media.DATA};
        Cursor cursor = getContentResolver().query(selectedImage,
                filePath, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePath[0]);
        picturePath = cursor.getString(columnIndex);
        cursor.close();

        if(picturePath != null)
        {
            File f = new File(picturePath);
            final ImageView imageView = (ImageView) findViewById(R.id.displayAddedPostPhoto);
            Picasso.with(this).load(f).resize(600,600).centerInside().into(imageView);
        }
    }
}

This is not loading image in the imageview on Android L devices while on the rest this works fine.

I tried it on a motorola android L 5.1.1 device with 2560 x 1440 image is not getting loaded

If I use Uri.fromFile I get the following message in logcat

Logcat shows :

 Throwing OutOfMemoryError "Failed to allocate a 18386956 byte allocation with 10384296 free bytes and 9MB until OOM"

来源:https://stackoverflow.com/questions/34149550/image-view-not-set-in-android-l-using-picasso-after-loading-from-gallery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!