android - 从解析中检索图像文件 - android

标签 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();
            }
        }

    });

我可以成功检索其他项目,但不是文件(我知道它存在并且在“图像”列下)。

提前致谢

最佳答案

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

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

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

Picasso.with(context).load(imageUri.toString()).into(mPostImage);

关于android - 从解析中检索图像文件 - android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24288466/

相关文章:

java - 如何将变量从 Activity 传递到 Adapter

android - 应用太大?无法执行 dex : Cannot merge new index into a non-jumbo instruction

parse-platform - 如何从 Parse 安装中检索设备 token

使用 Parse 和 PubNub 的 Android 聊天应用指南

ios - 如何强制异步保存常量子类?

ios - Parse.com和ios的安装和角标(Badge)问题

android - 亚马逊 Kindle 模拟器

android - Android 中如何比较当前时间与第二天时间?

java - 在 EditText 中输入文本时出现 NullPointerException

javascript - 是通过云代码从 REST 删除/放置对象的唯一方法吗? (Cors问题)