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