相机意图 android
当我开始相机意图时,我给它一个我希望它使用的文件名。当我在手机上收到此文件时,它使用手机默认文件名。这没有帮助,因为我稍后在应用程序中需要图像名称。
相机意图代码...
public void onClick(View view) {
String currentDateTimeString = DateFormat.getDateInstance().format(new Date());
System.out.println(currentDateTimeString);
filename = ("/sdcard/" + currentDateTimeString + ".jpg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), filename);
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
filetype = "image/jpeg";
}
When I begin the camera intent I give it a file name I would like it to use. When I get this on the phone it uses the phones default file name. Which is no help as I need the image name later in the app.
Camera intent code...
public void onClick(View view) {
String currentDateTimeString = DateFormat.getDateInstance().format(new Date());
System.out.println(currentDateTimeString);
filename = ("/sdcard/" + currentDateTimeString + ".jpg");
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), filename);
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
filetype = "image/jpeg";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
詹姆斯,
这是我用来捕获图像并将其保存到我选择的位置(带有我的应用程序名称的子文件夹)的功能。
James,
Here is the function I use to capture an image and save it to a location of my choosing (sub folder with my app name).