0

I'm trying to pick multiple images from users gallery and upload (parse server) this images to parse object then retrieve it and set it in an image view

and also i need to pick one image from gallery and save to the users profile

what i have already tried:

//Before OnCreate 
String da = "13412412412412414124ASDASDASDASDAD";
////After OnCreate
 @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        final Uri imageUri = data.getData();
        final InputStream imageStream;
        try {
            imageStream = getContentResolver().openInputStream(imageUri);
            final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
            String encodedImage = encodeImage(selectedImage);
            da=encodedImage;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
    private String encodeImage(Bitmap bm) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.PNG,100,baos);
        byte[] b = baos.toByteArray();
        String encImage = Base64.encodeToString(b, Base64.DEFAULT);
        return encImage;
    }
    private void ChooseImage() {
        Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
        photoPickerIntent.setType("image/*");
        startActivityForResult(photoPickerIntent, RESULT_LOAD_IMG);

    }
    private void CreateThing() {
        ParseObject thing = new ParseObject("Things");
        thing.put("Image",da);
        thing.saveInBackground(new SaveCallback() {
            @Override
            public void done(ParseException e) {
                if (e==null)
                    Toast.makeText(class.this, "Done", Toast.LENGTH_SHORT).show();
                else
                    Toast.makeText(class.this, e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        });
    }
3
  • Please specify the problem you are facing with code (Behavior/exception)? Commented Feb 8, 2020 at 21:46
  • @Kryptonian null pointer exception , but I'm searching for a new full guide for uploading images to parse server Commented Feb 9, 2020 at 17:01
  • 1
    This might help you stackoverflow.com/questions/16292853/… Commented Feb 10, 2020 at 14:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.