从parse中检索图像文件 - android

dan*_*223 3 android parse-platform

我正在尝试从我的应用中检索上传的图片:

intent = getIntent();
    String id = intent.getStringExtra("id");
    ParseQuery<ParseObject> query = ParseQuery.getQuery("Items");
    query.getInBackground(id, new GetCallback<ParseObject>()
    {
        @Override
        public void done(ParseObject object, ParseException e)
        {
            if (e == null)
            {
                setTitle(object.getString("name"));
                textPlatform.setText(object.getString("platform"));
                textPrice.setText(String.valueOf(object.getDouble("price")));
                textDelivery.setText(String.valueOf(object.getDouble("delivery")));
                textLocation.setText(object.getString("location"));
                textCondition.setText(object.getString("condition"));
                textSeller.setText(object.getString("seller"));
                ParseFile applicantResume = (ParseFile) object.get("image");
                applicantResume.getDataInBackground(new GetDataCallback()
                {
                    public void done(byte[] data, ParseException e)
                    {
                        if (e == null)
                        {
                            Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
                            imgItem.setImageBitmap(bmp);
                        }
                        else
                        {
                            e.printStackTrace();
                        }
                    }
                });
            } else
            {
                e.printStackTrace();
            }
        }

    });
Run Code Online (Sandbox Code Playgroud)

我可以成功检索其他项目而不是文件(我知道存在并位于"图像"列下).

先谢谢你

nat*_*ake 12

我是这样做的:我使用getParseFile方法从解析中获取文件:

ParseFile postImage = object.getParseFile(ParseConstants.PARSE_KEY_FILE);
String imageUrl = postImage.getUrl() ;//live url 
Uri imageUri = Uri.parse(imageUrl);
Run Code Online (Sandbox Code Playgroud)

然后我使用Picasso来显示图像:

Picasso.with(context).load(imageUri.toString()).into(mPostImage);
Run Code Online (Sandbox Code Playgroud)