Crashes and ANR Errors

Just an FYI for you guys… Two classes of systematic bugs I just killed in WordHero:

  1. If you access SharedPreferences from an onClick or anywhere where there is another thread. You HAVE to use a fully qualified ParentClass.this.mContext.SharedPrefs. Sure, just using SharedPrefs will compile and work… on most phones… but on others you will get weird problems (typically Android 2.2 or some cheap 2.3 phones) !

  2. If you have a game timer using runnable… see above. SharedPrefs need to be accessed using a full class name. ALSO: when the user quits, it is quite possible the timer loop will run one last time. So if it updates any resources, they may be null !!!

Thanks. Will keep this in mind (pun not intended?), since I use those SharedPrefs quite often.

Thanks for letting us know about these quirks! The Shared Preferences in onClick() is something I’ll have to look at… I think this occurs in several of my apps :-/

Oh … and SharedPrefs basically COMPLETELY DOES NOT WORK (ie: silently fails to save) on some cheap/shitty/old Android versions… you know, the type of tablet they sell cheap and it only does 640x400 on a 10" tablet !

I’ve struggled a lot with SharedPrefs before. It just seems really hard to predict their behaviour, and if they’re not behaving correctly the problems are mostly silent.

Yeah… but works on some devices and not on others??? wtf ?