MEDIA_TYPE_IMAGE not recognized

I am having problems with the resource for 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 cannot be resolved by a variable. I have a mediastar, camera, and URIs imported into my project. Thanks in advance!

+7
source share
4 answers

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 the Android developers blog, be sure to check the section for saving media files , there you have the constants created to handle this.

+16
source

Error: MEDIA_TYPE_IMAGE not recognized

Anwser: add a line to your class

 public static final int MEDIA_TYPE_IMAGE = 1; 
+5
source

if you try the camera example using the android manual read this
http://developer.android.com/guide/topics/media/camera.html#saving-media they declared a method at the bottom of the documentation

+1
source

You may not have provided good permissions in your manifest (e.g. camera access, external storage access, etc.).

0
source

All Articles