内容提供商INSTALL_FAILED_CONFLICTING_PROVIDER(安装内容提供商作为一个单独的APK) [英] Content Provider INSTALL_FAILED_CONFLICTING_PROVIDER (installing content provider as a separate apk)

查看:592
本文介绍了内容提供商INSTALL_FAILED_CONFLICTING_PROVIDER(安装内容提供商作为一个单独的APK)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用相同的内容提供商两个应用程序,但我不能把同样的内容提供商在这两个应用程序 - 它显示INSTALL_FAILED_CONFLICTING_PROVIDER错误。所以,我已经把我的内容提供商在第三的apk和两个应用程序中使用这一点,它运作良好。

I have two applications which use the same content provider, but I can't put the same content provider in both applications- it shows INSTALL_FAILED_CONFLICTING_PROVIDER error. So I have put my content provider in a 3rd .apk and used this from two applications and it is working well.

现在的问题是 - 在任何这两个应用程序可以在设备上安装了内容提供商的apk必须安装。否则,它显示在安装过程中提供未找到错误。

Now the problem is- The content provider apk must be installed before any of those two apps can be installed on the device. Otherwise, it shows Provider not found error during installation.

所以,我怎么能保证任何其他的apk的安装之前,供应商的apk安装?

So, how can I ensure that the provider apk is installed before any of the other apks is installed?

有没有办法单独合并内容提供商APK同时与其他的apk的,所以他们将一起安装的两个应用程序并不会显示INSTALL_FAILED_CONFLICTING_PROVIDER错误?

Is there a way to merge the content provider apk with both of the other apks separately, so they will be installed together as two applications and won't show INSTALL_FAILED_CONFLICTING_PROVIDER error?

我需要合并的内容提供商的apk两个应用程序,因为用户可能无法同时安装应用程序,也可以在单个设备上安装它们。

I need to merge the content provider apk with both applications, because the user may not install both applications or may install them both on a single device.

推荐答案

一个解决方案,我能想到的是,使这两个不同的包标识的internally.and出口的应用内容提供商组成部分它采用了android:出口= TRUE。双方可能会使用相同的code虽然。

One solution i can think of is, make content provider part of both the applications with different packageid's internally.and export it using android:exported = true. Both might be using the same code though.

在您检查其他内容供应商存在于设备上的应用程序的开始,如果它的存在,你开始使用它,否则你回退到本地内容提供商。另外安装一个应用时,它可以做同样的检查。

At the start of the application you check if the other content provider exists on the device if it's there you start using it,otherwise you fallback to local content provider. when the other applicaton installs it can does the same check.

要防止其他人你的cotent供应商,您可以定义自定义权限,以保护它,让您的应用程序只能使用它,或者你也可以把一些自定义的验证像一些密钥来访问内容提供商。你可以有这个认证code的内容提供者的所有方法。

To protect your cotent provider from everyone else, you can define a custom permission to protect it, so that your applications can only use it or you can also put some custom authentication like some secret key to access the content provider. you can have this authentication code in all methods of content provider.

这篇关于内容提供商INSTALL_FAILED_CONFLICTING_PROVIDER(安装内容提供商作为一个单独的APK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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