[英]Camera intent android
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";
}
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). 这是我用来捕获图像并将其保存到我选择的位置(具有我的应用名称的子文件夹)的功能。
public void imageFromCamera() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
Log.d(TAG, "No SDCARD");
} else {
mImageFile = new File(Environment.getExternalStorageDirectory()+File.separator+"MyApp",
"PIC"+System.currentTimeMillis()+".jpg");
mTempImagePath = mImageFile.getAbsolutePath();
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mImageFile));
startActivityForResult(intent, TAKE_PICTURE);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.