更新大量小部件位图时避免 FAILED BINDER TRANSACTION 错误

Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps(更新大量小部件位图时避免 FAILED BINDER TRANSACTION 错误)

本文介绍了更新大量小部件位图时避免 FAILED BINDER TRANSACTION 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 AppWidget 中更新 RemoteViews 时遇到错误.

I am coming across an error when I am updating my RemoteViews in my AppWidget.

.. !!!Binder 交易失败!!!

.. !!! FAILED BINDER TRANSACTION !!!

这是因为对 RemoteViews 的所有更改都是序列化的(例如 setInt 和 setImageViewBitmap ).位图也被序列化成一个内部包.不幸的是,这个捆绑包的大小限制非常小.

This is caused because all the changes to the RemoteViews are serialised (e.g. setInt and setImageViewBitmap ). The bitmaps are also serialised into an internal bundle. Unfortunately this bundle has a very small size limit.

我不能使用 setImageResource,因为我希望允许用户下载小部件的皮肤.

I cannot use setImageResource as I am hoping to allow the user to download skins for the widget.

谁能推荐一个解决这个问题的方法?我已经为小部件的每个实例使用了一个新"RemoteViews 对象,但是单个实例包含太多更新.

Can anyone recommend a workaround for this problem? I am already using a "new" RemoteViews object for each instance of the widget, but a single instance contains too many updates.

谢谢!

推荐答案

我发现的最佳解决方法是在 ImageView 对象上使用 setImageURI

The best workaround I found was to use setImageURI on the ImageView objects using

remoteViews.setUri(R.id.myImageView, "setImageURI", "file://blahblahblah.png");

这是来自 Android 开发者组的完整讨论

这篇关于更新大量小部件位图时避免 FAILED BINDER TRANSACTION 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:更新大量小部件位图时避免 FAILED BINDER TRANSACTION 错误

基础教程推荐