如何将图像正确下载到相机胶卷?

时间:2019-11-14 14:15:03

标签: java android android-studio

因此,我尝试通过onClickEvent按钮上的URL this image下载图像,但是由于某种原因,即使我已将其添加到webapis权限中,它仍然告诉我添加图像清单。

  

我正在使用API​​ 19

android.permission.WRITE_EXTERNAL_STORAGE

这就是我要下载的方式

<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"
    tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

这是个例外

this.btnDownload.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        //Download image
        imageToRoll();
        Toast.makeText(DisplayItemActivity.this, "Done!", Toast.LENGTH_SHORT).show();
    }
});

private void imageToRoll(){
    imageView.buildDrawingCache();
    Bitmap image = imageView.getDrawingCache();  // Gets the Bitmap
    MediaStore.Images.Media.insertImage(getContentResolver(), image, "imageName" , "testerDescription");  // Saves the image.
}

2 个答案:

答案 0 :(得分:0)

自Android 6.0起,WRITE_EXTERNAL_STORAGE是“ 危险”权限,因此用户必须在运行时接受它们,并且您的应用程序必须以正确的方式询问他们。 对于这些类型的权限,仅在清单中写入权限是不够的,但是您必须编写所有逻辑以在运行时询问权限。 这并不困难,只需阅读此官方指南即可: https://developer.android.com/training/permissions/requesting

,在这里您可以阅读有关危险权限的信息: https://developer.android.com/guide/topics/permissions/overview.html#dangerous-permission-prompt

答案 1 :(得分:0)

尝试:

Map<String, Object> orders = new HashMap<>()
        try {
            context.apiClient.getDAO(pl.bonita.integrator.OrderDAO.class).findByArchived(IsArchived, startIndex, maxRows)[0].with {
                Map<String, Object> order = new HashMap<>()
                if (!it) {
                    response = "No case with id ${processId}"
                }
                order.put("CaseId", it.getCaseId())
                order.put("AssignedName", it.assignedName)
                orders.put(it.getCaseId().toString(), order)
            }
        } catch (Exception e) {
            response = "Exception: " + e.getMessage()
        }
相关问题