onUpdate不在窗口小部件中调用,即使我看到onreceive中的android.appwidget.action.APPWIDGET_UPDATE意图

我正在使用仿真器使用调试器,我注意到onUpdate没有被调用.当我将窗口小部件添加到模拟器主屏幕时,我看到我的断点被onReceive方法击中. onReceive方法确实获取android.appwidget.action.APPWIDGET_UPDATE的意图.但是,onUpdate函数从不被调用.我相信它的定义是正确的.
@Override
        public void onUpdate(Context context,AppWidgetManager appWidgetManager,int[] appWidgetIds)
        {
    // code that sets up remove view and updates appWidgetManager


    }

解决方法

调用onReceive()中的超类方法
@Override
public void onReceive(Context context,Intent intent)
{
    // Chain up to the super class so the onEnabled,etc callbacks get dispatched
    super.onReceive(context,intent);
    // Handle a different Intent
   Log.d(TAG,"onReceive()" + intent.getAction());

}

如果您覆盖了您的子类appwidgetprovider中的onReceive(),则除非您调用超类,否则不会触发提供程序的onEnabled,onUpdate等回调.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...