2

Again having issues with Parse.com clearly I'm having issues with it. Once again it works perfectly in iOS but when I try to do the same thing in Android it fails. Error is: "Caused by: java.lang.NullPointerException" which calls this line of code "fileObject.getDataInBackground(new GetDataCallback()"

Basically, I'm trying to pull a specific image out of a parse.com table and display it within a ImageView. I have it working locally in other words I can call the image directly from the device. But this defeats the purpose of pulling the image from Parse.com.

I have followed the example provided on Parse.com website but clearly I'm not the only one having issues. https://parse.com/docs/android_guide#files

Below is my code located on the onCreate function;

ParseObject parseObject = new ParseObject("Birds");
ParseFile fileObject = (ParseFile) parseObject.get("totemImage");
fileObject.getDataInBackground(new GetDataCallback() {
    @Override
    public void done(byte[] data, ParseException e) {

        if (e == null)
        {
            Bitmap bmp = BitmapFactory .decodeByteArray(data, 0, data.length);
            ImageView pic;

            pic = (ImageView) findViewById(R.id.totemView);
            pic.setImageBitmap(bmp);

        }
        else
        {


        }

    }
}); 

Any ideas on how to fix this would be great. BTW (Birds is the table/classname in parse)

Regards, Jeremy

4

1 回答 1

6

代码的第一行是创建一个类名为 Birds 的新 ParseObject:

ParseObject parseObject = new ParseObject("Birds");

然后,在下一行,您正在读取它的“totemImage”键的值:

ParseFile fileObject = (ParseFile) parseObject.get("totemImage");

由于这是一个新对象,因此预计它的所有键都不会有任何值,因此 fileObject ParseFile 为空。

您确定您不是要查询现有对象吗?

于 2013-08-09T01:28:12.740 回答