gpt4 book ai didi

android - 从另一个应用复制文件

转载 作者:行者123 更新时间:2023-11-29 01:42:12 24 4
gpt4 key购买 nike

我使用以下代码将我的应用与文件扩展名 .vv 相关联:

         <intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="application/*" />
<data android:pathPattern=".*\\.vv" />
<data android:host="*" />
</intent-filter>

现在,当我从 DropBox 打开一个文件时,我的应用程序就会启动,我可以使用以下方法获取源文件的完整路径:

this.getIntent().getData().getPath()

但是,当我尝试以任何方式读取或复制它时(直接从路径,或使用 getContentResolver().openInputStream(uri) 从 uri),源文件出现 EACCES 异常.当我从 GMail 应用程序打开它时,我没有这个异常,但我从 DropBox 得到它。

我怎样才能读取/复制它?

最佳答案

使用“使用权限写外部存储”

<application>
...

</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
The uses-permission tag needs to be outside the application tag.

关于android - 从另一个应用复制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23801139/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com