« With more languages comes Expense Report | Main | Expense Report with file exporting feature »

22 February 2009

Action items for JPDialer

I have several things to do for JPDialer:

  • Replace the icon with new one, 48x48 pixel size.
  • URL on the “About” screen must points to JPDialer page instead of Dialer's.
  • React properly to screen rotation. Text fields must keep their contents when the user slides G1's keyboard.

The last one is most tricky. If the user slides the keyboard, Activity will be destroyed and be created again. (Note that the application itself is not destroyed.) This is somewhat overreaction from programmer's point of view whilst Google thinks different way:

  1. Sliding the keyboard and consequent screen rotation are configuration changes.
  2. Activity needs to set its parameters, especially, layout in accordance with the new configuration.
  3. Therefore, the framework destroys Activity and re-instantiates it. This is much easier than dynamically adjusting every parameter to the new configuration.

Okay, apart from this issue, Activity must prepare for being destroyed at any time. It must handle onSaveInstanceState() event notification and save its internal state, anyway. So, what can I do for it? Couples of options are:

  • Save internal state in onSaveInstanceState() and get it back in onCreate() or onRestoreInstanceState(). This is the most usual way to persist Activity's state.
  • Use onRetainNonConfigurationInstance() instead. This method can return any Object instance, in constrast with onSaveInstanceState() that sticks to Bundle. This is more convenient way.
  • Use onConfigurationChanged() callback. By adding an Activity's attribute <action:configChanges="keyboardHidden|orientation"> line to the application's manifest file, I can tell framework that I will handle configuration changes by myself. This is the most flexible way to handle keyboard sliding and screen rotation.

At least, I have to implement the first one so that JPDialer behaves as a good Android application. Then, probably the third option had better be added for optimisation purpose.


See articles on AndroidGuys, http://androidguys.com/?s=Rotational+Forces&x=0&y=0 for more details and more options.

|

« With more languages comes Expense Report | Main | Expense Report with file exporting feature »

Android」カテゴリの記事

JPDialer」カテゴリの記事

TrackBack

TrackBack URL for this entry:
http://app.cocolog-nifty.com/t/trackback/532178/45454881

Listed below are links to weblogs that reference Action items for JPDialer:

« With more languages comes Expense Report | Main | Expense Report with file exporting feature »