尝试调整Camera意图时出现以下异常:
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)
代码是:
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 );
}
}
答案 0 :(得分:6)
答案 1 :(得分:0)
我在启用XPrivacy时遇到类似的错误,并且某些权限被阻止。事实证明,所有媒体活动(保存音频,保存屏幕截图)都要通过“下载管理器,下载,媒体存储”软件包,然后需要“存储”类别(duh)中的getExternalStorageState
权限。< / p>
有趣的是,它还阻止内部(仿真)SD卡可以安装在PC上(使用MTP)。