android - sendBroadcast after asynctask (started in widget onReceive) completes -


goal: update widget view after asynctask completes.

scenario: widget onreceive receives intent user click. starts networking operation in asynctask. interface has been passed asynctask via constructor described here. in interface method, i'm trying send broadcast trigger widget's onupdate method don't believe firing.

thoughts: best guess onreceive has returned, therefore context trying use sendbroadcast no longer available. thinking get() asynctask don't want trigger anr if operation takes long. if get(timeout, unit) asynctask, i'm afraid risk missing end of task , view not updated.

what's best way update widget view upon completion of task?

solution: turns out made mistake crafting intent broadcasting

if can hold reference of view updated,then invoke view#onupdate in defined interface.if not,and want use broadcast inform view update,so suggest use localbroadcastmanager,then don't need worry if context exists now.hope you.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -