【发布时间】:2018-03-14 16:23:49
【问题描述】:
我有一个要求让我的应用程序编辑 PDF 文件。因为我发现很难集成到应用程序中,所以我决定使用外部应用程序并决定使用Xodo reader。
我遇到的问题是,当我的 pdf 在 Xodo 应用程序中打开并进行编辑时,它并没有保存到其原始位置,而是将副本保存到下载文件夹中。对我来说,这表明应用程序无法将编辑后的文件保存回原来的位置,我相信这是因为我做的不对。
我为什么会这样想?
当 Xodo 应用程序打开一个 .pdf 文件,然后在我回击时对其进行编辑时,它会将其保存到打开它的内存位置。当我用我的应用程序加载它时,它不会那样工作。
这是我的代码:
我如何调用应用程序
val target = view?.packageManager?.getLaunchIntentForPackage("com.xodo.pdf.reader")
target?.action = Intent.ACTION_EDIT
target?.setDataAndType(FileProvider.getUriForFile(context, view?.applicationContext?.packageName + ".fileprovider", report.file), "application/pdf")
target?.flags = Intent.FLAG_ACTIVITY_NO_HISTORY
target?.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
view?.startActivity(target)
我的@xml/provider_paths 是什么样子的
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="myApp" path="."/>
</paths>
我的文件在内存中的位置
/内部存储/myApp
我的内容 URI 是什么样的
content://com.example.myapp.debug.fileprovider/myApp/myApp/example0.pdf
有人知道我在哪里做错了吗?
【问题讨论】:
标签: android file android-intent kotlin android-fileprovider