I have got two working directories containing java code and resources, one is for testing and the other one is production.
src/main/java
src/main/resources
src/test/java
src/test/resources
When running my code and reading a file from FileInputStream like this:
new FileInputStream("./someFile.json");
Run Code Online (Sandbox Code Playgroud)
As long a the file is located in the root of the project this works fine. It also works if I have the file in the resource folder and point directly to it like this:
new FileInputStream("src/test/resources/someFile.json");
Is there a way …
在我的应用程序中,我提示用户捕获图像.用户相机活动从buttonClick开始,用户可以选择使用相机捕获图像.
此图像保存在用户手机上.然后将图像上传到firebase存储,一切正常.使用Samsung Note 8的一个用户的反馈是,当以纵向模式捕获图像时,他稍后在应用程序中以横向模式显示它.
我查看了firebase存储,发现图像以LANDSCAPE模式保存在存储中,即使用户以纵向模式捕获图像.
我想我必须将元数据传递给以纵向模式捕获图像的jpeg文件,以便firebase知道它实际上是纵向模式.
这是捕获图像的代码:
private void takePhoto() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
}
if (photoFile != null) {
imageUri = FileProvider.getUriForFile(this, "com.example.android.fileprovider", photoFile);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是CreateImageFile的方法:
public File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyy.MM.dd_HH:mm:ss").format(new Date());
String …Run Code Online (Sandbox Code Playgroud)