且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更新大量部件的位图时避免失败粘结剂事务错误

更新时间:2023-01-26 10:41:20

***的解决方法,我发现是使用 setImageURI ImageView的使用对象

  remoteViews.setUri(R.id.myImageView,setImageURI,文件://blahblahblah.png);
 

下面是从 Android开发组

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

.. !!! FAILED BINDER TRANSACTION !!!

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.

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

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.

Thanks!

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

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

Here is the full discussion from Android Developers group