1. Are you ready for the Galaxy S20? Here is everything we know so far!

Getting Parse Image

Discussion in 'Android Development' started by MrGoomer, Oct 14, 2020.

  1. MrGoomer

    MrGoomer Lurker
    Thread Starter

    Hello guys,
    I am facing this problem for half a day and I don't know the solution,a bit more and I am going crazy.

    I am trying to build instegram clone.Everytime I press on a name ,it should show me the images that the user uploaded, but I am facing a weird problem with parse.

    So I have 4 activities ,the last one should recieve the image that the user uploaded. However,parse isn't find the image of the user,but it finds the user name just fine.


    This is how my data looks like:
    https://pasteboard.co/JvBOWAr.png

    and this is my code:



    @override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_profile);

    linearLayout = findViewById(R.id.mLinearLayout);


    Intent intent = getIntent();

    String username = intent.getStringExtra("username");

    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Image");


    query.whereEqualTo("username", username);

    query.orderByDescending("createdAt");

    query.findInBackground(new FindCallback<ParseObject>() {
    @override
    public void done(List<ParseObject> objects, ParseException e) {
    if (e == null && objects.size() > 0) {
    for (ParseObject object : objects) {
    ParseFile file = (ParseFile) object.get("image");

    file.getDataInBackground(new GetDataCallback() {
    @override
    public void done(byte[] data, ParseException e) {
    if (e == null && data != null) {
    Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0,data.length);
    ImageView imageView = new ImageView(getApplicationContext());

    imageView.setLayoutParams(new ViewGroup.LayoutParams(
    ViewGroup.LayoutParams.MATCH_PARENT,
    ViewGroup.LayoutParams.WRAP_CONTENT
    ));

    imageView.setImageBitmap(bitmap);

    linearLayout.addView(imageView);
    }
    }
    });
    }
    }
    else{
    Log.e("NO OBJECTS FOUND","NO OBJECTS FOUND");
    }
    }
    });

    }

    I am getting the log "No objects found" and no picture is showing.

    However,when I am deleting this line:

    query.whereEqualTo("username", username);

    I get random picture that the users uploaded,and everyime I press another profile,I get another random picture of a user.


    Thanks for all the helpers..
     



    1. Download the Forums for Android™ app!


      Download

       
  2. MrGoomer

    MrGoomer Lurker
    Thread Starter

    I am very sorry for the double but I can't edit my post:

    My code:

    Code (Java):
    1. @Override
    2.     protected void onCreate(Bundle savedInstanceState) {
    3.         super.onCreate(savedInstanceState);
    4.         setContentView(R.layout.activity_user_profile);
    5.  
    6.         linearLayout = findViewById(R.id.mLinearLayout);
    7.  
    8.  
    9.         Intent intent = getIntent();
    10.  
    11.          String username = intent.getStringExtra("username");
    12.  
    13.         ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Image");
    14.  
    15.  
    16.         query.whereEqualTo("username", username);
    17.  
    18.         query.orderByDescending("createdAt");
    19.  
    20.         query.findInBackground(new FindCallback<ParseObject>() {
    21.             @Override
    22.             public void done(List<ParseObject> objects, ParseException e) {
    23.                 if (e == null && objects.size() > 0) {
    24.                     for (ParseObject object : objects) {
    25.                         ParseFile file = (ParseFile) object.get("image");
    26.  
    27.                         file.getDataInBackground(new GetDataCallback() {
    28.                             @Override
    29.                             public void done(byte[] data, ParseException e) {
    30.                                 if (e == null && data != null) {
    31.                                     Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0,data.length);
    32.                                     ImageView imageView = new ImageView(getApplicationContext());
    33.  
    34.                                     imageView.setLayoutParams(new ViewGroup.LayoutParams(
    35.                                             ViewGroup.LayoutParams.MATCH_PARENT,
    36.                                             ViewGroup.LayoutParams.WRAP_CONTENT
    37.                                     ));
    38.  
    39.                                     imageView.setImageBitmap(bitmap);
    40.  
    41.                                     linearLayout.addView(imageView);
    42.                                 }
    43.                             }
    44.                         });
    45.                     }
    46.                 }
    47.                 else{
    48.                     Log.e("NO OBJECTS FOUND","NO OBJECTS FOUND");
    49.                 }
    50.             }
    51.         });
    52.  
    53.         }
     
Loading...
Similar Threads - Getting Parse Image
  1. sublime_excision
    Replies:
    5
    Views:
    321
  2. tinker123
    Replies:
    2
    Views:
    402
  3. Gobshyte
    Replies:
    2
    Views:
    365
  4. Brecht_Kelchtermans99
    Replies:
    2
    Views:
    373
  5. Bruce McH
    Replies:
    11
    Views:
    736
  6. Kiwi_gamer01
    Replies:
    0
    Views:
    356
  7. Jeff Whiteis
    Replies:
    1
    Views:
    530
  8. Gobshyte
    Replies:
    1
    Views:
    355
  9. DanCalling
    Replies:
    11
    Views:
    565
  10. MoodyBlues
    Replies:
    9
    Views:
    518

Share This Page

Loading...