【问题标题】:Error in geting Image from Action_Image_Capture Intent从 Action_Image_Capture Intent 获取图像时出错
【发布时间】:2015-01-09 19:59:38
【问题描述】:

我正在使用 ACTION_IMAGE_CAPTURE 来使用 Intent 从相机捕获图像。 我正在使用此代码:

    Intent i = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
            //startActivity(i);
            startActivityForResult(i,1);

并通过此代码获取意图结果:

      InputStream stream = null;
    if (requestCode == 1 && resultCode == Activity.RESULT_OK)
        try
        {
            // recyle unused bitmaps
            if (bitmap != null) {
                bitmap.recycle();
            }
            stream = getContentResolver().openInputStream(data.getData());
            bitmap = BitmapFactory.decodeStream(stream);

            imgPic.setImageBitmap(bitmap);
        } catch (FileNotFoundException e)
        {
            //e.printStackTrace();
            Log.e("ERROR 2 :->",e.toString());
        }

            if (stream != null)
            {
                try
                {
                    stream.close();
                } catch (IOException e)
                {
                    //e.printStackTrace();
                    Log.e("ERROR 3 :->",e.toString());
                }
            }

    }

但是当我点击图片预览意图中的勾选按钮时,它会给我这个错误:

     1-10 00:55:34.675  25036-25036/com.digicare.digitrick W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x40e3d258)
       01-10 00:55:34.686  25036-25036/com.digicare.digitrick E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity 

我在哪里遗漏了一些东西???? 如何在 ImageView 中获取捕获的图像?

【问题讨论】:

  • 你能发布你的整个 onActivityResult 吗?
  • Andro Selva 这是完整的代码。只是错过了起跑线。 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  • 然后可能尝试在第一行调用 super.onactivityResult() 。这可能会有所帮助..

标签: android android-intent


【解决方案1】:

可能是你的Activity在Camera Activity操作过程中被销毁,之后又重新创建,因为Camera APP资源占用很大。 您可以尝试轮换您的 Activity 以强制您的 Activity 销毁并重新创建以检查问题。

查看更多信息~ why is UI/Activity destroyed after onActivityResult

【讨论】:

    猜你喜欢
    • 2011-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多