Android的Facebook内容提供者权限 [英] Android Facebook content provider authority

查看:190
本文介绍了Android的Facebook内容提供者权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含(至少)两种具有不同包名称的应用程序,因此实际上是Android系统的两个不同的应用程序。该应用程序使用Facebook共享,因此我在清单中声明了提供者:

I'm developing an app with (at least) two flavors having different package names - therefore actually two different apps as far as the android system is concerned. The app uses Facebook sharing, so I have the provider declared in the manifest:

<provider android:authorities="com.facebook.app.FacebookContentProvider{app id here}"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>

这是根据Facebook的说明完成的: https://developers.facebook.com/docs/sharing/android

This is done according to Facebook's instructions: https://developers.facebook.com/docs/sharing/android

但尝试在同一设备上安装第二个应用程序失败,并显示错误INSTALL_FAILED_CONFLICTING_PROVIDER。这是清单中定义的唯一提供者,所以我很确定是问题。如果我将提供程序字符串更改为不同的尝试打开Facebook共享对话框时崩溃的字符串。

This works fine with one app, but trying to install the second app on the same device fails with the error INSTALL_FAILED_CONFLICTING_PROVIDER. This is the only provider defined in the manifest so I'm pretty sure it's the problem. If I change the provider string to be something different it crashes when attempting to open a Facebook share dialog.

我已经看到声称可以在多个Android应用程序中使用相同的Facebook应用程序,但在Facebook的文档中找不到任何内容。有没有人这样做,你是如何解决提供者权限的问题?谢谢。

I've seen claims that it's possible to use the same Facebook app in multiple android apps, but can't find anything in Facebook's documentation about it. Has anybody done this, and how did you get around the provider authority problem? Thanks.

推荐答案

我可以通过为我的调试和发布风格和调试风格清单中分别提供清单来解决这个问题,我添加了提供者的代码段,但将导出的值设置为false。在我的发布音乐清单中,我的原始提供程序代码段导出设置为true。

I was able to solve this by having separate manifests for my debug and release flavors and in my debug flavor manifest, I added the snippet for the provider but set the exported value to false. In my release flavor manifest, I have the original provider snippet with exported set to true.

在我这样做之后,我不再有INSTALL_FAILED_CONFLICTING_PROVIDER错误。

After I did this, I no longer got the INSTALL_FAILED_CONFLICTING_PROVIDER error.

<provider android:authorities="com.facebook.app.FacebookContentProvider{app id here}"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="false"/>

这篇关于Android的Facebook内容提供者权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆