Android上的开放式摄像头代码在三星S3中不起作用



我有以下代码可以在Android中从我的应用程序打开相机应用程序。它在三星Galaxy Nexus上运行良好,但在三星GalaxyS3上崩溃,不幸的是,我没有后一种设备来调试问题,有什么建议吗?

    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    File dir = new File(Environment.getExternalStorageDirectory() + File.separator + this.getString(R.string.kda_images));
    File file = new File(Environment.getExternalStorageDirectory() + File.separator + this.getString(R.string.kda_images) + File.separator + "Image-" + dir.listFiles().length + ".jpg");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));//The selected image is created in the specified location: file
    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));//Refreshes the directory to show the new image
    startActivityForResult(intent, CAPTURE_NEW_IMAGE);

请尝试使用以下代码,因为我认为它在galaxy s3设备中可以正常工作。

Intent action=new Intent("android.media.action.IMAGE_CAPTURE")action.putExtra(MediaStore.EXTRA_OUTPUT,MediaStore.Images.Media.EEXTERNAL_CONTENT_URI.toString());startActivityForResult(动作,TAKE_PICTURE_FROM_CAMERA);

最新更新