it looks like in the existing code  we are already calling invalidateoptionsmenu around the same time we are calling drawtoppanel  how about if we get rid of your flag and always call invalidateoptionsmenu in drawtoppanel  you ll want to remove the existing calls to invalidateoptionsmenu where drawtoppanel is called at the same time 