4

I get the following exception when trying to tun Camera intent:

10-31 20:49:43.297: ERROR/DatabaseUtils(194): Writing exception to parcel
10-31 20:49:43.297: ERROR/DatabaseUtils(194): java.lang.UnsupportedOperationException: Unknown URI: content://media/external/images/media
10-31 20:49:43.297: ERROR/DatabaseUtils(194):     at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:1696)
10-31 20:49:43.297: ERROR/DatabaseUtils(194):     at com.android.providers.media.MediaProvider.insert(MediaProvider.java:1638)
10-31 20:49:43.297: ERROR/DatabaseUtils(194):     at android.content.ContentProvider$Transport.insert(ContentProvider.java:174)
10-31 20:49:43.297: ERROR/DatabaseUtils(194):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146)
10-31 20:49:43.297: ERROR/DatabaseUtils(194):     at android.os.Binder.execTransact(Binder.java:288)
10-31 20:49:43.297: ERROR/DatabaseUtils(194):     at dalvik.system.NativeStart.run(Native Method)
10-31 20:49:43.297: DEBUG/AndroidRuntime(583): Shutting down VM
10-31 20:49:43.308: WARN/dalvikvm(583): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-31 20:49:43.337: ERROR/AndroidRuntime(583): FATAL EXCEPTION: main
10-31 20:49:43.337: ERROR/AndroidRuntime(583): java.lang.UnsupportedOperationException: Unknown URI: content://media/external/images/media
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:146)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.content.ContentProviderProxy.insert(ContentProviderNative.java:408)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.content.ContentResolver.insert(ContentResolver.java:587)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at org.BJ.Food4All.utils.CameraUtil.TakePicture(CameraUtil.java:46)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at org.BJ.Food4All.Activities.NewRecipe.Instructions.onContextItemSelected(Instructions.java:132)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.app.Activity.onMenuItemSelected(Activity.java:2199)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback.onMenuItemSelected(PhoneWindow.java:2744)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:137)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:874)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.widget.AdapterView.performItemClick(AdapterView.java:284)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.widget.ListView.performItemClick(ListView.java:3382)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.os.Handler.handleCallback(Handler.java:587)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.os.Looper.loop(Looper.java:123)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at android.app.ActivityThread.main(ActivityThread.java:4627)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at java.lang.reflect.Method.invokeNative(Native Method)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at java.lang.reflect.Method.invoke(Method.java:521)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-31 20:49:43.337: ERROR/AndroidRuntime(583):     at dalvik.system.NativeStart.main(Native Method)

code is:

public void TakePicture() 
{
    mFileName                   = "LetFindANewName.jpg"; // TODO - update name
    ContentValues contentValues = new ContentValues();

    contentValues.put( MediaStore.Images.Media.TITLE,       mFileName );
    contentValues.put( MediaStore.Images.Media.DESCRIPTION, "Image capture by camera" ); // TODO- update description for recipe name description

    mImageUri = mParentActivity.getContentResolver().insert(
                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
                        contentValues );

    //create new Camera Intent
    Intent intent = new Intent( MediaStore.ACTION_IMAGE_CAPTURE );
    intent.putExtra( MediaStore.EXTRA_OUTPUT,           mImageUri );
    intent.putExtra( MediaStore.EXTRA_VIDEO_QUALITY,    1 );

    try
    {
        mParentActivity.startActivityForResult( intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE );
    }
    catch( Exception e )
    {
        Toast.makeText( mParentActivity.getApplicationContext(),
                        "Error while starting Camera!",
                        Toast.LENGTH_LONG ).show();

        Log.e( mTAG, "Failed to start camera" );
        Log.e( mTAG, e.getMessage(), e );
    }
}
Peter G.
  • 14,786
  • 7
  • 57
  • 75
Yoav
  • 635
  • 2
  • 11
  • 29

2 Answers2

6

I bet you forgot to insert the SD card

Reno
  • 33,594
  • 11
  • 89
  • 102
  • It is in the emulator. I found that taking pictures is not supported in the emulator, but regarding the path - in the emulator - why not good? – Yoav Nov 01 '11 at 08:21
  • 2
    [Read this to know how to](http://rickiedroid.blogspot.com/2011/04/add-sdcard-in-android-emulator-setup.html) setup the sd-card in the emulator. If you want to support taking pictures in the emulator, use [this](http://stackoverflow.com/questions/1276450/how-to-use-web-camera-in-android-emulator-to-capture-a-live-image) or [this](http://www.tomgibara.com/android/camera-source) – Reno Nov 01 '11 at 08:34
  • 2
    Even if you are using a device that has an SD card you might see this error when the device is connected to a PC/Mac via USB since some OSes mount the SD card making it unaccessible for Android. – Volker Voecking Aug 03 '12 at 05:58
0

I hit a similar error with XPrivacy enabled, and some permissions are blocked. As it turns out, all media activities (save audio, save screenshot) go through the "Download Manager, Downloads, Media Storage" package, which then needs the getExternalStorageState permission in the "Storage" category (duh).

Interestingly enough, it also blocks the internal (emulated) SD card from being mountable on a PC (using MTP).

trapezoid
  • 101
  • 1
  • 3