寻找一些关于错误的帮助,我正在尝试存储用相机拍摄的照片,我试图开发的应用程序.错误是
java.lang.IllegalArgumentException:无法找到包含/ storage/emulated/0/Pictures/JPEG20161108_153704_的已配置根目录
logcat在我的代码中指向FileProvider.getUriForFile的行中指向此方法.
private void dispatchTakePhoto() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivity(takePictureIntent); // this worked originally
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException e) {
e.printStackTrace();
Log.e(TAG, ""+e);
}
if (photoFile != null) {
Uri photoURI = FileProvider.getUriForFile(TallyActivity2.this,
"com.example.bigdaddy.pipelinepipetally.fileprovider", photoFile);
takePictureIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}
}
Run Code Online (Sandbox Code Playgroud)
此方法用于创建图像文件
private File createImageFile() throws IOException {
/* Create an image file name */
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new …Run Code Online (Sandbox Code Playgroud) Flask 新手,正在尝试编写教程,但遇到了render_template()方法中上下文变量的一些问题。
这是app.py:
from flask import Flask, render_template, url_for
app = Flask(__name__)
posts = [
{
'author': 'Some Author',
'title': 'Blog Post 1',
'content': 'First blog post',
'date_posted': 'April 21, 2018'
},
{
'author': 'Another Author',
'title': 'Blog Post 2',
'content': 'Second blog post',
'date_posted': 'May 21, 2013'
}
]
@app.route("/")
@app.route("/home")
def home():
return render_template('home.html', posts=posts)
@app.route("/about")
def about():
return render_template('about.html')
if __name__ == '__main__':
app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)
这是我的home.html模板:
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
</head> …Run Code Online (Sandbox Code Playgroud)