Android如何在gallary中查看sdcard中的doc?

Nik*_*k88 5 search android document gallery sd-card

我有应用程序,用户可以从SD卡搜索图像,音频,视频,doc文件,并选择1个文件上传它在服务器上.使用下面的代码我可以打开图库并选择图像,音频,视频但我不知道如何从库中搜索文档.

这是我的代码.

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_GET_CONTENT);
    //intent.setType("video/*");
    //intent.setType("audio/*");
    //intent.setType("image/*");
    //**What I have to do for view document[.pdf/text/doc] file**
    startActivityForResult(Intent.createChooser(intent, "Complete action using"), REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)

有谁知道如何实现这一目标?任何帮助是极大的赞赏.

abb*_*efa 0

希望这会帮助您打开文档

public void openDOC(String name) {


        File file = new File(Environment.getExternalStorageDirectory() + "/"
                + bmodel.getUserMasterBO().getUserid() + "/" + name);
        if (file.exists()) {
            Uri path = Uri.fromFile(file);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(path, "application/msword");
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(this, "No Application Available to View DOC",
                        Toast.LENGTH_SHORT).show();
            }
        }

    }
Run Code Online (Sandbox Code Playgroud)