android - (Reflective) Method call delivers same old results until app is force stopped and restarted (...is there something automatically cached somehow?) -


i have strange problem , hope of has idea happens here.

my app structure follows:

  • i have main service registers broadcast receiver , listens intents screen on/off etc. service runs indefinitely.
  • when such intent received, start service action
  • inside action service launch asynctask fetch battery related stats via reflection. after service done, calls stopself().

so works expected, except when battery related infos have been fetched 1 time, each subsequent call of asynctask/reflection methods deliver same result has been delivered before.

the battery stats have of course been updated in meantime, not new updated numbers, stats first method call.

that until go settings , force stop , restart app, updated battery statistics again, @ least 1 time, because after i'm stuck these numbers again.

so question: results of reflection call automatically cached somewhere , each subsequent call doesn't fetch new data delivers cached results? else problem?

i'm thankful ideas, need code lemme know :)

ok, i've found fix :))

the library of better battery stats uses singleton pattern needed class. includes invalidate() function, sets singleton instance null, @ next getinstance() gets reinitialized.

i'm using invalidate after each statisitics fetch, , updated statistics on every call. although still not sure why singleton pattern seems root of issue, should work having 1 initialized singleton instance...

well, 1 not have understand ;-)


Comments