[英]Taking a picture through camera using Intent and saving it in the database in android
I have created an activity that starts camera intent to take pictures. 我创建了一个活动,该活动开始使相机开始拍照。 it run normally and takes pictures but the problem is that I am not been able to store it in the database.
它可以正常运行并拍照,但问题是我无法将其存储在数据库中。 Any suggestions or some code.
任何建议或一些代码。 thanks in advance.
提前致谢。
Use this to take your picture. 用它来拍照。
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(),"image.jpg");
Uri inputFileUri = Uri.fromFile(file);
System.out.println("outputFileUri in camera===>"+inputFileUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, inputFileUri);
intent.putExtra("return-data", true);
startActivityForResult(intent, 1);
And in on activity result use its uri. 并在活动结果中使用其uri。
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
Uri outputFileUri=data.getData();
//here by using uri you can also saves image to sd card.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.