Java 如何在Android Studio中与应用程序共享文件

Java 如何在Android Studio中与应用程序共享文件,java,android,file,share,Java,Android,File,Share,我是Android编程新手,我正在尝试与应用程序共享文件,因为我已经尝试过: final Uri arquivo = Uri.fromFile(new File(absoluteFileName)); final Intent _intent = new Intent(); try { _intent.setAction(Intent.ACTION_SEND); _intent.putExtra(Intent.EXT

我是Android编程新手,我正在尝试与应用程序共享文件,因为我已经尝试过:

final Uri arquivo = Uri.fromFile(new File(absoluteFileName));
        final Intent _intent = new Intent();
        try {
            _intent.setAction(Intent.ACTION_SEND);
            _intent.putExtra(Intent.EXTRA_STREAM, arquivo);
            _intent.putExtra(Intent.EXTRA_TEXT, "Venho informar a perda de um material com o seguinte anexo: ");
            _intent.putExtra(Intent.EXTRA_TITLE, "Meu pdf");
            _intent.setType("application/pdf");

            startActivity(Intent.createChooser(_intent, "Compartilhar"));
        }catch (Exception error){
            //Toast.makeText(getBaseContext(),"Ocorreu um erro ao criar o seu relatório", Toast.LENGTH_LONG).show();

        }

出现以下错误:E/storaged:getDiskStats失败,结果不受支持,大小为0


如何在Android的顶级API 29上共享文件?

“出现以下错误:E/storaged:getDiskStats失败,结果不受支持,大小为0”-这似乎与您的应用程序无关
Uri.fromFile()
自Android 7.0以来已过时。使用
FileProvider
getUriForFile()
获取一个
Uri
用于
ACTION\u SEND
。已尝试,但错误仍然存在。同样,该错误消息似乎与您的应用程序无关。如果您认为您的应用程序正在崩溃,您应该在Logcat中找到堆栈跟踪。