How to detect if photo was taken (camera intent)

klijakub

I want to send a photo taken by camera intent.

  • Camera works fine
  • I have path from mMediaUri.getPath() (it's correct)
  • I have method to send it (postImage()) (works fine)

When I start an Intent, camera is showing up, but method postImage is not waiting until photo is taken. PostImage just loading after starting intent.

How to load postImage after photo was taken?

or

How to detect if photo was taken?

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        mMediaUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
        if(mMediaUri == null){
          Toast.makeText(MainActivity.this, "Problem!", Toast.LENGTH_LONG).show();

        }
        else {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mMediaUri);
            startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);

            postImage("mail", mMediaUri.getPath());

        }

    }

enter image description here

Oğuzhan Döngül

Simply you can use that for opening camera:

static final int REQUEST_IMAGE_CAPTURE = 1;

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

and for detecting capture(OK or Cancel button)

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        Bitmap imageBitmap = (Bitmap) extras.get("data");
        mImageView.setImageBitmap(imageBitmap);
    }
}

Do not forget giving permission:

<manifest ... >
    <uses-feature android:name="android.hardware.camera"
                  android:required="true" />
    ...
</manifest>

Also check these links:

http://developer.android.com/training/camera/photobasics.html https://developer.android.com/training/camera/index.html

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Photo taken through camera intent is losing on quality

From Dev

How can i set an image taken from the Camera intent into a ImageView?

From Dev

Detect Camera photo folder

From Dev

Android camera and photo picker intent

From Dev

How to detect user has tapped "Use Photo" button in the camera?

From Dev

Trying to display image taken from camera intent

From Dev

How to add taken photo to MediaStore

From Dev

Custom camera shows dark picture preview when photo taken on Nexus

From Dev

Android Camera: Get Picture Uri after the photo is taken

From Dev

Is it possible to check if an image is taken by camera or uploaded from photo library by JavaScript?

From Dev

Android: Can't get the size of photo taken by camera acitivity

From Dev

Android - Saving photo taken from Camera , Out of memory

From Dev

ImageView does not display image taken from phone camera or photo gallery

From Dev

How to find out when was a photo taken?

From Dev

Android Cordova - How to draw photo taken on canvas?

From Dev

Take photo w/ camera intent and display in imageView or textView?

From Dev

Android : Take a photo from with in my layout without starting a camera intent

From Dev

How to detect edges of a colored photo?

From Dev

How to set photo taken with UIImagePickerController to be viewed/modified into a custom UIViewController?

From Dev

Swift - how to get last taken 3 photos from photo library?

From Dev

How to add sticker overlay to camera photo

From Dev

How capture photo of camera periodically from service?

From Dev

How to detect the camera disconnection in linux?

From Dev

Android: how to detect if camera flashed

From Dev

how to detect an image with iPhone camera?

From Dev

How to detect if front camera is active

From Dev

Picture taken by intent and saved temp, how to display on imageview?

From Dev

How do I detect if a photo is a poster (not realistic)?

From Dev

How to determine whether an image was taken from the library or from the camera

Related Related

  1. 1

    Photo taken through camera intent is losing on quality

  2. 2

    How can i set an image taken from the Camera intent into a ImageView?

  3. 3

    Detect Camera photo folder

  4. 4

    Android camera and photo picker intent

  5. 5

    How to detect user has tapped "Use Photo" button in the camera?

  6. 6

    Trying to display image taken from camera intent

  7. 7

    How to add taken photo to MediaStore

  8. 8

    Custom camera shows dark picture preview when photo taken on Nexus

  9. 9

    Android Camera: Get Picture Uri after the photo is taken

  10. 10

    Is it possible to check if an image is taken by camera or uploaded from photo library by JavaScript?

  11. 11

    Android: Can't get the size of photo taken by camera acitivity

  12. 12

    Android - Saving photo taken from Camera , Out of memory

  13. 13

    ImageView does not display image taken from phone camera or photo gallery

  14. 14

    How to find out when was a photo taken?

  15. 15

    Android Cordova - How to draw photo taken on canvas?

  16. 16

    Take photo w/ camera intent and display in imageView or textView?

  17. 17

    Android : Take a photo from with in my layout without starting a camera intent

  18. 18

    How to detect edges of a colored photo?

  19. 19

    How to set photo taken with UIImagePickerController to be viewed/modified into a custom UIViewController?

  20. 20

    Swift - how to get last taken 3 photos from photo library?

  21. 21

    How to add sticker overlay to camera photo

  22. 22

    How capture photo of camera periodically from service?

  23. 23

    How to detect the camera disconnection in linux?

  24. 24

    Android: how to detect if camera flashed

  25. 25

    how to detect an image with iPhone camera?

  26. 26

    How to detect if front camera is active

  27. 27

    Picture taken by intent and saved temp, how to display on imageview?

  28. 28

    How do I detect if a photo is a poster (not realistic)?

  29. 29

    How to determine whether an image was taken from the library or from the camera

HotTag

Archive