8

I'm having trouble with the resource on android developers for the camera, here is my code:

// create Intent to take a picture and return control to the calling application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

// create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

The problem is 'MEDIA_TYPE_IMAGE' which says that it can not be resolved to a variable. I got mediastore, camera and URI imported into my project. Thanks in advance!

Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151
user1337210
  • 241
  • 3
  • 6
  • 11

4 Answers4

16

Try importing android.provider.MediaStore.Files.FileColumns and change MEDIA_TYPE_IMAGE to FileColumns.MEDIA_TYPE_IMAGE.

If you are using the sample code from Android developers blog be sure to check the section about saving media files, there you have the constants created to handle that.

nicael
  • 18,550
  • 13
  • 57
  • 90
Alejandro Moya
  • 434
  • 6
  • 11
5

Quession: MEDIA_TYPE_IMAGE not recognized

Anwser: Please add row in your class

public static final int MEDIA_TYPE_IMAGE = 1;
Thien Nguyen
  • 928
  • 10
  • 12
  • 3
    I didn't understand this answer until I found this code here: http://developer.android.com/guide/topics/media/camera.html#saving-media – el_stack May 11 '13 at 04:08
2

if you are trying the camera example from the android guide then read this
http://developer.android.com/guide/topics/media/camera.html#saving-media they have declared the method at the bottom of the documentation

Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52
0

Could be that you didn't give the good permissions in your Manifest (such as Camera access, external storage access, etc.)

zeroxgames
  • 640
  • 2
  • 9
  • 13