android - Button inside a Widget ListView does not trigger Broadcast -
my widget single listview number of elements. should clickable through listview , since elements have 2 buttons, should clickable, too. desired action on button click broadcast, while list element click should open activity (which works).
the receiver registered in manifest , has corresponding intent-filter.
in remoteviewsfactory.getviewat(int position)
done add pendingintent:
private void registerbuttonlistener(remoteviews remoteview, int id, int zoneid) { intent intent = new intent(widgettemperaturereceiver.action); intent.putextra("id", zoneid); intent.putextra("up", id == r.id.buttontempup); intent.setclassname(widgettemperaturereceiver.class.getpackage().getname(), widgettemperaturereceiver.class.getname()); pendingintent pending = pendingintent.getbroadcast(context.getapplicationcontext(), 0, intent, pendingintent.flag_update_current); remoteview.setonclickpendingintent(id, pending); }
however nothing received. ideas why?
i'm guessing package name or class name not being passed in properly.
instead of this:
intent.setclassname(widgettemperaturereceiver.class.getpackage().getname(), widgettemperaturereceiver.class.getname());
use this:
intent.setclass(context, widgettemperaturereceiver.class);
where context
reference activity
or service
or whatever component executing method in.
Comments
Post a Comment