android - 资源管理器在我的应用中使用

标签 android audio filesystems

当我单击按钮时,程序会询问我要使用哪个文件管理器(或Dropbox等)。然后,我选择例如.mp3文件。当我需要它时,如何告诉我的程序启动此.mp3?如何记住这个选择的文件?

ring_button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent_for_ring_button = new Intent();
                intent_for_ring_button.setAction(Intent.ACTION_GET_CONTENT);
                File file = new File(REPORTS_DIRECTORY);
                intent_for_ring_button.setDataAndType(Uri.fromFile(file),"application/file");
                startActivityForResult(Intent.createChooser(intent_for_ring_button,"Open folder"), 0);
            }
        });

最佳答案

试试这个

Uri myUri = Uri.parse(entry.getFile());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(myUri, "audio/*");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

关于android - 资源管理器在我的应用中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32923927/

相关文章:

linux - 在 GDB 中创建简单的事件处理程序,如 inotify

Android Time.format ("%a")给出错误的星期几

c# - 我的着色器在桌面上工作,但屏幕在 Android 上变黑

javascript - 资源被解释为文档,但在Chrome控制台中因MIME类型音频/mpeg错误传输,导致无法播放声音

android - 我可以在 Android 中为多个用户创建共享文件夹吗?

c# - 如何确定某个用户是否对文件或文件夹具有(有效)读取权限?

java - Android 中索引 3 无效,大小为 0

android - 光标下划线

javascript - 将 PCM 数据附加到 MediaSource

c++ - 使用FFmpeg或OpenAL的音频均衡器