在WidgetProvider的onUpdate里,用registerReceiver方法将自己注册了监听ACTION_BATTERY_CHANGED的Intent。将Widget拖到Home上,之前都是可以监听到的,但是过一会就收不到了,有人遇到过这种情况吗?谢谢

解决方案 »

  1.   

    在Reference里找到答案了:Note: this method cannot be called from a BroadcastReceiver component; that is, from a BroadcastReceiver that is declared in an application's manifest. It is okay, however, to call this method from another BroadcastReceiver that has itself been registered at run time with registerReceiver(BroadcastReceiver, IntentFilter), since the lifetime of such a registered BroadcastReceiver is tied to the object that registered it.