gpt4 book ai didi

android - 多进程内容提供者同步到默认一个

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:59:54 25 4
gpt4 key购买 nike

根据 Android documentation :

android:multiprocess

Whether or not an instance of the content provider can be created in every client process — "true" if instances can run in multiple processes, and "false" if not. The default value is "false".

Normally, a content provider is instantiated in the process of the application that defined it. However, if this flag is set to "true", the system can create an instance in every process where there's a client that wants to interact with it, thus avoiding the overhead of interprocess communication.

因此,如果此属性设置为true,那么将在每个进程中创建一个Content Provider 实例。

问题 1 这个实例是对内容提供者的引用还是整个内容提供者的副本?

问题 2 系统如何处理将更改同步回默认/原始实现?是不是数据源(SQLite等)负责多进程读/写?

问题 3 这更像是一个有根据的猜测。最初,在拥有内容提供者的应用程序中有内容提供者实例。每当其他应用程序与其交互时,它们都会通过 IPC 进行交互,这意味着:

other app --> IPC --> content provider --> data source

设置multiprocess="true" 时,系统会在每个进程中创建内容提供者的副本。因此,应用程序无需通过 IPC 即可与内容提供者进行交互。

other app ---> content provider ---> data source

内容提供者仍然可以直接访问数据源。在这种情况下,它的方法必须是线程/进程安全的,因为其他应用程序也会访问它。

如果这个场景是正确的,这个线程安全实现是否不同于线程安全的默认要求?

最佳答案

好问题,遗憾的是我找到了答案,它是:不要使用此属性。

Don't use this, it is some old cruft from pre-1.0 design that doesn'twork and should be ignored these days. Just pretend like theattribute doesn't exist. :}

...

Dianne Hackbor

Android framework engineer

https://groups.google.com/forum/#!topic/android-developers/u9UMJtALSXw

我创建了一个问题,要求将其正确记录: https://code.google.com/p/android/issues/detail?id=217916

2020 年 12 月更新(6 年后):问题仍未解决,我在这里打开了一个新报告: https://issuetracker.google.com/issues/175708197

关于android - 多进程内容提供者同步到默认一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24790845/

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