我正在尝试将uri传递到相机意图时将完整的相机图像保存到指定的Uri。但它没有返回onActvityResult。但是,我尝试在onActivityResult中使用Bundle获取图像,但它返回一个缩略图。我尝试了很多教程,他们都遇到了这个问题。你可以帮忙!!!
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File u = getTempFile();
picUri = Uri.fromFile(u);
camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(u));
startActivityForResult(camera, TAKE_PICTURE);
onActivityResult
if (requestCode == TAKE_PICTURE && resultCode == RESULT_OK && null != data)
{
Toast.makeText(this, "Image saved to:\n"+picUri, Toast.LENGTH_LONG).show();
}
答案 0 :(得分:0)
尝试下面给出的代码:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = new File(android.os.Environment
.getExternalStorageDirectory(), "temp.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(intent, REQUEST_CAMERA);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_CAMERA) {
File f = new File(Environment.getExternalStorageDirectory()
.toString());
for (File temp : f.listFiles()) {
if (temp.getName().equals("temp.jpg")) {
f = temp;
break;
}
}
String path = f.getAbsolutePath();
} }
}