android – 如何使FileProvider可用于其他应用程序?

android – 如何使FileProvider可用于其他应用程序?,第1张

概述是否可以将FileProvider用于其他应用程序? 的manifest.xml ... <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.myapp.fileprovider" android:expo 是否可以将fileProvIDer用于其他应用程序?

的manifest.xml

... <provIDer        androID:name="androID.support.v4.content.fileProvIDer"        androID:authoritIEs="com.example.myapp.fileprovIDer"        androID:exported="true"        androID:grantUriPermissions="false"        androID:permission="com.example.filesvisible.permission.READ" >        <Meta-data            androID:name="androID.support.file_PROVIDER_PATHS"            androID:resource="@xml/filespath" />    </provIDer>...

从doc:

false: The provIDer is not available to other applications. Set
androID:exported=”false” to limit access to the provIDer to your
applications. Only applications that have the same user ID (UID) as
the provIDer will have access to it.

我试图将导出设置为true但我得到了这个例外
无法获取提供程序androID.support.v4.content.fileProvIDer:java.lang.SecurityException:不能导出提供程序为什么我无法导出fileProvIDer?

解决方法

Is it possible to have a fileProvIDer available to other applications ?

是.这通常就是重点.

Why I can’t export a fileProvIDer ?

因为这不是您使用fileProvIDer的方式.

fileProvIDer背后的点是give select access to files to third-party apps.您可以通过FLAG_GRANT_READ_URI_PERMISSION和/或FLAG_GRANT_WRITE_URI_PERMISSION在用于将您的提供者的Uri值之一传递给第三方应用程序的Intent中执行此 *** 作(例如,通过与startActivity一起使用的ACTION_VIEW Intent( )).

另见the training guide on sharing files.

总结

以上是内存溢出为你收集整理的android – 如何使FileProvider可用于其他应用程序?全部内容,希望文章能够帮你解决android – 如何使FileProvider可用于其他应用程序?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1136608.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存