如何访问下载文件夹?

时间:2018-03-29 23:24:38

标签: android apk

我正在尝试从设备的下载目录安装void phantom::createFrameBuffer() { swapChainFramebuffers.resize(swapChainImageViews.size()); for (size_t i = 0; i < swapChainImageViews.size(); i++) { std::vector<VkImageView> attachments = { swapChainImageViews[i], depthImageView }; VkFramebufferCreateInfo framebufferInfo = {}; framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; framebufferInfo.renderPass = renderPass; framebufferInfo.attachmentCount = attachments.size(); framebufferInfo.pAttachments = attachments.data(); framebufferInfo.width = swapChainExtend.width; framebufferInfo.height = swapChainExtend.height; framebufferInfo.layers = 1; if (vkCreateFramebuffer(device, &framebufferInfo, nullptr, &swapChainFramebuffers[i]) != VK_SUCCESS) { throw std::runtime_error("failed to create framebuffer!"); } } } 。我的硬编码解决方案就像一个魅力 -

apk

但是一旦我将其更改为

   Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "update.apk")), "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

我解析了包错误。我做错了什么????

1 个答案:

答案 0 :(得分:0)

返回的值
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)

/ storage / emulated / 0 / Download 最后错过了一个'/'。你的路径应该是'/update.apk'

您需要按如下方式使用它:

intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/update.apk")), "application/vnd.android.package-archive");