Goal: update a widget view after AsyncTask
completes.
Scenario: widget onReceive
receives an intent from a user click. This starts a networking operation in an AsyncTask
. An interface
has been passed to the AsyncTask
via constructor as described here. In the interface
method, I'm trying to send a broadcast that will trigger the widget's onUpdate
method but I don't believe that it is firing.
Thoughts: My best guess is that onReceive
has returned, therefore the Context
that I was trying to use to sendBroadcast
is no longer available. I was thinking that I could get()
the AsyncTask
but I don't want to trigger ANR if the operation takes too long. If I get(timeout, unit)
the AsyncTask
, I'm afraid that I risk missing the end of the task and the view will not be updated.
What's the best way to update the widget view upon completion of the task?
Solution: Turns out that I made a mistake crafting the Intent
that I was broadcasting