小编J21*_*12O的帖子

java.lang.IllegalArgumentException:无法找到包含/ storage/emulated/0/Pictures /的已配置根目录

寻找一些关于错误的帮助,我正在尝试存储用相机拍摄的照片,我试图开发的应用程序.错误是

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)

java android

11
推荐指数
4
解决办法
2万
查看次数

Flask 上下文变量在模板中不可用

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)

jinja2 flask python-3.6

1
推荐指数
1
解决办法
3483
查看次数

标签 统计

android ×1

flask ×1

java ×1

jinja2 ×1

python-3.6 ×1