从图库加载后,使用Picasso在Android L中未设置图像视图

时间:2015-12-08 06:39:13

标签: android picasso

@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);
        }
    }
}

这不是在Android L设备上的imageview中加载图像,而在其余部分,这可以正常工作。

我试用了摩托罗拉android L 5.1.1设备,2560 x 1440图像没有加载

如果我使用Uri.fromFile,我会在logcat中收到以下消息

Logcat shows :

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

0 个答案:

没有答案