Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- imageView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
- startActivityForResult(cameraIntent, 1);
- }
- });
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == 1 && resultCode == -1) {
- image = (Bitmap) data.getExtras().get("data");
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- // Must compress the Image to reduce image size to make upload easy
- image.compress(Bitmap.CompressFormat.PNG, 50, stream);
- byte[] byte_arr = stream.toByteArray();
- // Encode Image to String
- encodedString = Base64.encodeToString(byte_arr, 0);
- Uri selectedImageUri = data.getData();
- img_path = getRealPathFromURI(selectedImageUri);
- // Uri tempUri = getImageUri(getApplicationContext(), image);
- imageView.setImageBitmap(image);
- imageView.setScaleType(ImageView.ScaleType.FIT_XY);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement