Here is my code
public void invalidateWidget(boolean invalidateUsingCaches) {
mUpdatingWidget = true;
if (invalidateUsingCaches) {
widget.invalidateUsingCaches();
if (widget.isRefreshRequired()) {
widget.initializeRefreshRequired();
mWidgetUpdateHandler.removeMessages(handlerMessage);
mWidgetUpdateHandler.sendEmptyMessageDelayed(handlerMessage,
handlerDelay);
}
} else {
widget.invalidate(false);
}
refreshImageView();
mUpdatingWidget = false;
}
This line
mWidgetUpdateHandler.sendEmptyMessageDelayed(handlerMessage,
handlerDelay);
causes imageview to not update with changes on phones with android versions 2.3 but works on newer android versions.
So far I have tried the following:
imageview.invalidate();- used a runnable with handler.
activity.runOnUiThread();
Remember the code works on newer android versions. Well it should work on all versions as the code follows Android guidelines.
Does anybody has a clue why this should be happenning? Solution?
Is MessageQueue has something to do here?
The problem was with supplying new bitmap to imageview. In handler’s handleMessage() I was giving new bitmap to the imageview which caused it to not refresh with changes. The handler worked fine. Though I still don’t understand why imageview refused new bitmap on old android versions.
I solved the problem by keeping the same bitmap.