2

I'm creating an app (basic, low-level clone of Instagram) where a user can see images other users have posted. However, I can;t seem to download the image from Parse into Android. I attach my code. I just want to let you know I do NOT get an error, NOR my app crashes. My app works fine, but it just won't show anything on my app. Can anyone tell me what I am doing wrong? Thanks!

public class User extends AppCompatActivity {
    static String title;
    RelativeLayout relativeLayout;

     @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user);
        setTitle(title);
        relativeLayout = (RelativeLayout) findViewById(R.id.relativeLayout);

        ParseQuery<ParseObject> query = ParseQuery.getQuery("Images");
        query.whereEqualTo("username", title);
        query.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> objects, ParseException e) {
                if(e==null){
                    for(ParseObject object : objects){
                        Log.i("info", "image found!");
                        ParseFile file = (ParseFile) object.get("image");
                        file.getDataInBackground(new GetDataCallback() {
                            @Override
                            public void done(byte[] data, ParseException e) {
                                if(e==null){
                                    Bitmap bitmapImage = BitmapFactory.decodeByteArray(data, 0, data.length);
                                    ImageView image = new ImageView(getApplicationContext());
                                    image.setImageBitmap(bitmapImage);
                                    relativeLayout.addView(image);
                                }
                                else{
                                    Log.i("info", e.getMessage());
                                }
                            }
                        });
                    }
                }
                else{
                    Log.i("info", e.getMessage());
                }
            }
        });
    }
}
rici
  • 234,347
  • 28
  • 237
  • 341

1 Answers1

1

I solved it. The problem was the ACL. It was set on private, and therefore my application was getting an Object array with size 0. I set it on public and it works now.

I hope this was the right way of doing it. Idk if I should leave ACL as public.