Android 安卓应用程序在nexus上从摄像头拍照时崩溃
当我们单击从相机拍摄的图像上的“确定”时,应用程序崩溃。问题存在于谷歌nexus设备上,适用于其他设备 错误日志Android 安卓应用程序在nexus上从摄像头拍照时崩溃,android,camera,Android,Camera,当我们单击从相机拍摄的图像上的“确定”时,应用程序崩溃。问题存在于谷歌nexus设备上,适用于其他设备 错误日志 11-12 14:25:30.059: E/AndroidRuntime(5386): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=Intent { act=inline-data (has extras) }} to
11-12 14:25:30.059: E/AndroidRuntime(5386): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1888, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.pocketbookkeeper/com.pocketbookkeeper.Photo_New_Entry}: java.lang.NullPointerException
启动照相机活动的代码
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 1888);
Uri selectedImage = imageReturnedIntent.getData();
用于从摄影机活动中检索数据的代码
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 1888);
Uri selectedImage = imageReturnedIntent.getData();
这一行imageReturnedIntent.getData()返回null。请注意,只有在我使用google nexus设备时才会发生这种情况。图像返回到带有“data”键的extras中,而不是
意图的数据部分。这样做:
Bundle extras = imageReturnedIntent.getExtras();
mImageBitmap = (Bitmap) extras.get("data");