首页 > 解决方案 > 我的 android 应用程序如何找到从 PC 下载的文件?

问题描述

我将文件从 PC 上传到我的 android 手机。我想从应用程序中打开此文件。在网上可以找到许多示例代码,但在我的环境中都没有。该应用程序提出了几个可以处理此意图的应用程序,但它们都显示了一个空的下载目录。我的代码是:

    Intent intent = new Intent();
    intent.setAction(DownloadManager.ACTION_VIEW_DOWNLOADS);

    try {
        startActivityForResult(
                Intent.createChooser(intent, "Select a File to Upload"),
                FILE_SELECT_CODE);
    } catch (android.content.ActivityNotFoundException ex) {
        // Potentially direct the user to the Market with a Dialog
        Toast.makeText(this, "Please install a File Manager.",
                Toast.LENGTH_SHORT).show();
    }

已设置 READ_EXTERNAL_STORAGE 和 WRITE_EXTERNAL_STORAGE 权限。

有任何想法吗 ?

标签: androiddownload

解决方案


推荐阅读