意向图像捕捉数据== NULL [英] Intent Image Capture data==null

查看:125
本文介绍了意向图像捕捉数据== NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的code和它完美的作品在爱立信XPERIA,但是当我测试了三星ACE应用程序,出现错误:


  

数据= NULL


 字符串文件= Environment.getExternalStorageDirectory()getAbsolutePath()+/picture.jpg。    意图I =新意图(android.provider.MediaStore.ACTION_IM​​AGE_CAPTURE);
    乌里输出= Uri.fromFile(新文件(archivo));
    i.putExtra(MediaStore.EXTRA_OUTPUT,输出);
    startActivityForResult(ⅰ,CAMERA_REQUEST);

OnActivity结果

 如果(要求code == CAMERA_REQUEST&放大器;&安培;结果code == RESULT_OK){
                    捆绑额外= data.getExtras();
                    BMP =(位图)extras.get(数据);
                    image.setImageBitmap(BMP);
                    image.setVisibility(0);

任何想法,为什么会这样?


解决方案

当您使用 EXTRA_OUTPUT 并指定文件你平时不通过的结果得到任何图像数据意图作为一个额外的。相机应用,而不是应该将数据写入到您指定的文件。

如果您有额外的,而不是一旦你收到你应该阅读您的文件输出 RESULT_OK 。或者你可以删除 EXTRA_OUTPUT ,使所有设备上的结果数据的意图可靠。请注意,这会返回一个低分辨率的图片,因为意图系统没有建立,提供大量的数据。

I have this code, and it works perfectly in an Ericsson XPERIA, but when I test the app in a SAMSUNG ACE, appears the error :

data=null

String  file=Environment.getExternalStorageDirectory().getAbsolutePath()+ "/picture.jpg";

    Intent i=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);  
    Uri output = Uri.fromFile(new File(archivo));           
    i.putExtra(MediaStore.EXTRA_OUTPUT, output);
    startActivityForResult(i,CAMERA_REQUEST);

OnActivity Result

if (requestCode==CAMERA_REQUEST && resultCode==RESULT_OK){
                    Bundle extras=data.getExtras();
                    bmp=(Bitmap)extras.get("data");
                    image.setImageBitmap(bmp);
                    image.setVisibility(0);

Any idea why this is happening?

解决方案

When you use EXTRA_OUTPUT and specify a file you usually don't get any image data via the result intent as an extra. The camera app is instead supposed to write the data to the file you specified.

If you include that extra you should read the output from your file instead once you receive RESULT_OK. Or you can remove EXTRA_OUTPUT to make data in the result intent reliable on all devices. Note that this returns a low-resolution picture since the intent system is not build to deliver huge amounts of data.

这篇关于意向图像捕捉数据== NULL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆