1

Create an activity that opens the camera, takes pictures and saves them to the SD card

I'm new to Android, I have been assigned a task whereby I need to create a activity which opens camera and takes photo and saves it to memory (Internal/external).

Any idea how to proceed please?

Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61
Praneeth
  • 1,260
  • 18
  • 37
  • 2
    Search on **Google**. You will get any many solutions. – M D Apr 15 '15 at 05:01
  • If you think it is a Repeated question please send the link to the answers and delete this question! I wont mind, I need sollution! – Praneeth Apr 17 '15 at 06:24
  • See my above comment. – M D Apr 17 '15 at 06:25
  • If I got the solution from google why would I come and ask here? – Praneeth Apr 17 '15 at 06:28
  • This is not your IT support service, if you really can't find the duplicates yourself, you're going to have a bad time programming, because you're going to need searching skills more than anything else. But we are not here to just "give u da codez", read the help section and avoid frustration ... – 2Dee Jul 12 '15 at 13:31

1 Answers1

0

-Use this Simplecrop library Download it and

Call this code to take picture[as per documented in that page..]:-

Intent intent = new Intent(this, CropImage.class);

// tell CropImage activity to look for image to crop 
String filePath = ...;
intent.putExtra(CropImage.IMAGE_PATH, filePath);

// allow CropImage activity to rescale image
intent.putExtra(CropImage.SCALE, true);

// if the aspect ratio is fixed to ratio 3/2
intent.putExtra(CropImage.ASPECT_X, 3);
intent.putExtra(CropImage.ASPECT_Y, 2);

// start activity CropImage with certain request code and listen
// for result
startActivityForResult(intent, REQUEST_CODE_CROP_IMAGE);

-Onactivityresult Method will be as per below code:-

if (resultCode != RESULT_OK) {

    return;
}  

switch (requestCode) {

    case REQUEST_CODE_CROP_IMAGE:

        String path = data.getStringExtra(CropImage.IMAGE_PATH);

        // if nothing received
        if (path == null) {

            return;
        }

        // cropped bitmap
        Bitmap bitmap = BitmapFactory.decodeFile(mFileTemp.getPath());

        break;
}
super.onActivityResult(requestCode, resultCode, data);

NOTE:- I explained it because you are new to android and can get it still ask whenever you get stuck at any point regarding this example.

Thanks!

Hardy
  • 2,576
  • 1
  • 23
  • 45