Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

how to get file from parse.com in android?

here is my db structure of purchased_item enter image description here

and here is my image table enter image description here

i want to get file FFNglxekCv

ParseQuery<ParseObject> query = ParseQuery.getQuery(KEY_MASTER_PURCHASED_ITEM);
    ParseUser currentUser = ParseUser.getCurrentUser();


    user.setObjectId(currentUser.getObjectId());*/

    query.whereEqualTo(KEY_PURCHASED_BY, currentUser);
    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> parseObjectList, ParseException e) {
            hideProgressDialog();
            if (e == null) {

                if (!parseObjectList.isEmpty()) {

                    for (int i = 0; i < parseObjectList.size(); i++) {

                        ParseObject parseObject = parseObjectList.get(i);

                     // ParseFile parseFile =(ParseFile) parseObject.getParseFile("image");


                        Log.e(TAG,TAG);
                    }
                }

            } else {
                if (!e.getLocalizedMessage().equalsIgnoreCase(""))
                    showErrorToast(e.getLocalizedMessage(), true);
                else
                    showErrorToast(getString(R.string.no_response_from_server), true);
                Log.d(TAG, "Error: " + e.getMessage());
            }
        }
    });

i dont know how to get image from parse.com

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm using Back4App! Could you please try something like the below?

ParseQuery<ParseObject> query = ParseQuery.getQuery("Photo");
        query.whereEqualTo("objectId", FFNglxekCv);
        query.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> objects, ParseException e) {
                if(e==null){
                    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){
                                    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());
                }
            }
        });

Let I kow if it's working for you!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...