TransactionTooLargeEception试图获得的应用程序的安装列表时应用程序、列表、TransactionTooLargeEception

2023-09-04 11:51:46 作者:fickle in love 花心

由于我的应用程序的一部分,我得到使用ApplicationPackageManager.getInstalledApplications安装在设备上的应用程序列表,但对于某些用户,我得到的崩溃报​​告说,

As part of my app I get a list of apps installed on the device by using ApplicationPackageManager.getInstalledApplications but for some users I get crash reports saying that

TransactionTooLargeException在android.osBinderProxy.tranasact(本机方法)

TransactionTooLargeException at android.osBinderProxy.tranasact(Native Method)

谁能想到,为什么我会得到这个?

Can anyone think why I'd get this?

推荐答案

这异常是正常情况下重现那种困难。当传输数据时,有IPC内存耗尽,你会得到这个异​​常。这可以发生在这两种情况下,其中一个服务试图将数据放置到客户端或客户端将数据发送到服务。最有可能你的一些用户可能已经安装了数量庞大的应用程序,这会导致数据的大小大于1MB(这是IPC缓冲区的大小)。

This exception is kind of difficult to reproduce under normal circumstances. You will get this exception when there IPC memory is exhausted when transferring data. This can occur in both cases, where a service is trying to place data to client or a client is sending data to service. Most probably some of your users might have installed huge number of application, which results in a data size greater than 1MB (which is the size of IPC buffer).

恐怕在这种情况下,你会不会做的更好的东西。但是,如果你正在做的事情一样,applyBatch,可以单独一个大交易到多个较小的交易。

I am afraid in this case, you will not be do anything better. But if you are doing something like, applyBatch, you can separate one large transaction to multiple smaller transactions.

另外看看这个线程What做对TransactionTooLargeException