Android onReceive not called -
i'm trying follow example: what correct way sharing data among appwidgetprovider , remoteviewsservice.remoteviewsfactory
as such, have remoteviewsfactory
has this:
@override public void ondatasetchanged() { // subsequent calls data. newsgetter.updatelistfeed(null, new newsgetter.onupdatelistfeedfinishedlistener() { @override public void onupdatelistfeedfinished(volleyerror error) { //async return here volley intent widgetupdateintent = new intent(newswidgetbase.feed_updated); widgetupdateintent.putextra(appwidgetmanager.extra_appwidget_id, appwidgetid); localbroadcastmanager.getinstance(context).sendbroadcast(widgetupdateintent); } }); log.e(tag, "******************************** ondatasetchanged provider"); }
then have appwidgetprovider
has this:
@override public void onreceive(context context, intent intent) { final string action = intent.getaction(); if (appwidgetmanager.action_appwidget_update.equals(action)) { log.e("widgetbase", "******************************** onreceive action_appwidget_update"); } else if (feed_updated.equals(action)) { log.e("widgetbase", "******************************** onreceive feed_updated"); appwidgetmanager appwidgetmanager = appwidgetmanager.getinstance(context); int appwidgetid = intent.getintextra(appwidgetmanager.extra_appwidget_id, appwidgetmanager.invalid_appwidget_id); updateappwidget(context, appwidgetmanager, appwidgetid); } super.onreceive(context, intent); }
and in manifest:
<receiver android:name=".widgets.a"> <intent-filter> <action android:name="android.appwidget.action.appwidget_update" /> <action android:name="com.myapp.feed_updated" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/abc" /> </receiver>
i debugger log action_appwidget_update
, own intent broadcast, never fires onreceive
(breakpoint never hit). see i'm doing wrong?
for own intent broadcast
work, have register
broadcastreceiver
programmatically. register receiver
localbroadcastmanager.getinstance(this).registerreceiver(yourwidgetreceiver, new intentfilter("your_intent_action"));
and send broadcast as
intent intent = new intent("your_intent_action"); localbroadcastmanager.getinstance(getapplicationcontext()).sendbroadcast(intent)
;
hope helps.
Comments
Post a Comment