我有以下代码可以在我的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);
答案 0 :(得分:0)
请尝试使用以下代码,因为我认为它在galaxy s3设备中正常工作。
Intent action = new Intent(“android.media.action.IMAGE_CAPTURE”) action.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI.toString()); startActivityForResult(动作,TAKE_PICTURE_FROM_CAMERA);