I am trying to upload photos to parse.com (the user must select photos from the Gallery and upload to parse.com). I have the following code:
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.send_guest_photo); imageView = (ImageView) findViewById(R.id.image_view); Button button_choose_guest_photo = (Button)findViewById(R.id.button_choose_guest_photo); button_choose_guest_photo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openGallery(); } }); } public void openGallery() { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, GALLERY_REQUEST); // SendPhoto(); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && requestCode == GALLERY_REQUEST) { Uri imageUri = data.getData(); imageView.setImageURI(imageUri); SendPhoto(); } } public void SendPhoto(){ Button button_send_guest_photo = (Button)findViewById(R.id.button_send_guest_photo); button_send_guest_photo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BitmapDrawable bitmapDrawable = (BitmapDrawable) imageView.getDrawable(); Bitmap b2 = bitmapDrawable.getBitmap(); ByteArrayOutputStream bos2 = new ByteArrayOutputStream(); b2.compress(Bitmap.CompressFormat.PNG, 1, bos2); img = bos2.toByteArray(); ParseObject gameScore = new ParseObject("guestsImages"); gameScore.put("photos", img); gameScore.saveInBackground(); } }); } But the photo does not load. Please show me where in the code I act incorrectly?