Friday, November 6, 2009

KeyboardView problem

A few days ago I tried playing with KeyboardView to make my own virtual keyboard for a little application. I had a big surprise which cost me a couple of hours (around 4-5). I even posted an issue here. Nothing special happened and no one responded to my post. I took the matter into my own hands and tried again different ways. I managed to locate the bug: THE CONTEXT. You cannot create a KeyboardView using the application context. You HAVE to use the Activity context. The developers from Android SDK said "they HAD to make the application context, but it doesn't really do anything" !? Maybe they SHOULD have warned the developers about the RISKS of using it. And by the way, if you use the Activity context and manage the orientation change event you WILL experience the memory leaks and the application crash.
So kids, do not play with Context at home. And if you do choose carefully whether to have memory leaks or to create your own KeyboardView (or maybe better, your own Android SDK).

No comments:

Post a Comment