here is my problem, when i try to get the Uri from the picture that I take whit the camera i get null with the camera on emulator and my device, but only whit the system camera if I use another camera app, always works. Here is my code
For launch the camera app
takePic.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
String captured_image = System.currentTimeMillis() + ".jpg";
File file = new File(Environment.getExternalStorageDirectory(), captured_image);
captured_image = file.getAbsolutePath();
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
intent.putExtra("return-data", true);
startActivityForResult(intent, CAMERA_REQUEST);
}
});
for get the image
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST) {
ContentResolver cr = getContentResolver();
InputStream in = null;
try
{
in = cr.openInputStream(outputFileUri);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
}
outputFileUri always have null when the activity returns.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…