【问题标题】:Android app crash on taking picture from camera on nexusAndroid应用程序在nexus上从相机拍照时崩溃
【发布时间】:2013-11-12 09:09:53
【问题描述】:

当我们在从相机拍摄的图像上单击“确定”时,应用程序崩溃。 google 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 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();

这行 imageReturnedIntent.getData() 返回 null。请注意,这只发生在我使用 google nexus 设备时。

【问题讨论】:

    标签: android camera


    【解决方案1】:

    图片是在带有“data”键的 extras 中返回的,而不是在 Intentdata 部分中返回的。像这样得到它:

    Bundle extras = imageReturnedIntent.getExtras();
    mImageBitmap = (Bitmap) extras.get("data");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      相关资源
      最近更新 更多