Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Android应用程序上读取字节[]作为音频文件_Java_Android_Audio_Android Intent_Android Fileprovider - Fatal编程技术网

Java 在Android应用程序上读取字节[]作为音频文件

Java 在Android应用程序上读取字节[]作为音频文件,java,android,audio,android-intent,android-fileprovider,Java,Android,Audio,Android Intent,Android Fileprovider,我正在制作一个Android应用程序,希望用户将字节[]作为音频文件读取。我的SDK版本是24。 首先,我将字节[]记录在一个文件中: public void enregistrerFichierAudio(byte[] b) { File test = new File("LOCAL_FILE.txt"); try{ FileOutputStream fos = new FileOutputStream(test);

我正在制作一个Android应用程序,希望用户将字节[]作为音频文件读取。我的SDK版本是24。 首先,我将字节[]记录在一个文件中:

public void enregistrerFichierAudio(byte[] b) {
        File test = new File("LOCAL_FILE.txt");
        try{
            FileOutputStream fos = new FileOutputStream(test);
            fos.write(b);
            fos.close();
        } catch(Exception e){}
}
然后我尝试用下面的代码打开一个音频意图:

Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("LOCAL_FILE.txt");
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent);
不幸的是,我有以下错误:

 FATAL EXCEPTION: main                                                                             
 Process: com.refereetimer.TimerMyActivity, PID: 20842
 android.os.FileUriExposedException: file:///LOCAL_FILE.txt exposed beyond app through Intent.getData()
 at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
有人知道我为什么会犯这个错误吗?感谢阅读此邮件。

可能重复的可能重复的