widget心得

 生命周期:

onEnable(第一次添加时调用)---onUpdate(每添加一个都会调用)-----onDeleted(每删除一个都会调用,包括最后一个)-----onDisabled(全部删除时才会调用)

 

//onReceive 来自广播,因为widget本身就是使用的广播机制

在生命周期开始前,都会向系统发送以下对应的广播。

 action:  android.appwidget.action.APPWIDGET_ENABLED

 action:  android.appwidget.action.APPWIDGET_UPDATE

 android.appwidget.action.APPWIDGET_DELETED

 android.appwidget.action.APPWIDGET_DISABLED

 

 

!!! FAILED BINDER TRANSACTION !!!问题解决方案:

1.让美工将图片做小

2.设置图片时,可以换做setURL/setInt

3.BitmapFactory.Options opts = new BitmapFactory.Options();
   opts.inSampleSize = 2;

   //

If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory. The sample size is the number of pixels in either dimension that correspond to a single pixel in the decoded bitmap. For example, inSampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16 the number of pixels. Any value <= 1 is treated the same as 1. Note: the decoder will try to fulfill this request, but the resulting bitmap may have different dimensions that precisely what has been requested. Also, powers of 2 are often faster/easier for the decoder to honor.

4. 每次更新的时候 都需要new RemoteViews。 (ComponentName  AppWidgetManager不需要每次都new)

 

 

widget居中的问题,

屏幕一般都是4x4的, 一个格子的大小为72dpx72dp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值