1

There is problem here when post bitmap in string through volley it will post very small image with small resolution although I set 100 for quality

    private void takeImage() {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
            selectedImage = data.getData();
            photo = (Bitmap) data.getExtras().get("data");

            String[] filepath = {MediaStore.Images.Media.DATA};

            Cursor cursor = getContentResolver().query(selectedImage, filepath, null, null, null);
            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filepath[0]);
            picturePath = cursor.getColumnName(columnIndex);
            cursor.close();

            Bitmap photo = (Bitmap) data.getExtras().get("data");
            imageView = (ImageView) findViewById(R.id.tokenImage);
            imageView.setImageBitmap(photo);

        }
    }


......


ByteArrayOutputStream bao = new ByteArrayOutputStream();
            photo.compress(Bitmap.CompressFormat.JPEG, 100, bao);
            byte[] by = bao.toByteArray();
            bitmap1 = Base64.encodeToString(by, Base64.DEFAULT);

======================================================

majed
  • 11
  • 1
  • this is terrible, you shouldn't be sending files via Volley. it is NOT built for that – thepoosh Mar 21 '16 at 12:00
  • @thepoosh take a look https://www.simplifiedcoding.net/android-volley-tutorial-to-upload-image-to-server/ – majed Mar 21 '16 at 12:49
  • 1
    I suggest strongly reading docs for this library `Volley is not suitable for large download or streaming operations, since Volley holds all responses in memory during parsing. For large download operations, consider using an alternative like DownloadManager.` http://developer.android.com/training/volley/index.html – thepoosh Mar 21 '16 at 14:59

1 Answers1

0

You've to send multipart request, it was described in: MultipartPostRequest

But as @thepoosh mentioned, volley is not best bet for you.

Community
  • 1
  • 1
3mpty
  • 1,354
  • 8
  • 16