Tuesday, January 7, 2014

Screen Management in Android, J2ME and BlackBerry

If we follow the following, we can give a good user experience.

1. As Android gives Fragments, (which was to manage the views in Tab devices mainly, I use it to reduce the number of Activities in the application), J2ME application should have minimum of two Displayables (Form, List, Canvas and GameCanvas) in the memory at a time, similarly minimum of MainScreen, FullScreen or PopupScreen at a time.

You can use IDs, and double buffering to repaint or show 'screens' on same displayable.

2. Keep minimum of Objects in the global objects, and remember to destroy them when no longer in use. So you must have onDestroy() for each 'screen' or 'fragments' you show in the view.

3. Use Adapter or WeakReference techniques to show the items in a list view; Pagination or Pull to Refresh techniques to show limited views on a View. Lazy loading to create and destroy the image objects once loaded in the SDCard memory from the network.

4. All the IOExceptions should be handled in a background thread as in AsyncTask in Android, and if the result is to be shown on the screen, use bundles to pass to it as a serialized object and update in the UI Thread. This feature is not in J2ME, but BlackBerry and Android have it.

5. In Android the concept of LocalBroadCast Manager can be used in communication between Services and Activities combining preferences. In BlackBerry you have GlobalEventManager and PersistentStorage, but you should transfer all the responses in both from IO Thread to another thread preferably a UI Thread, as the event manager should not wait, and to ensure proper UI refresh on the active screen. While there is a background operation, show a progress bar to prohibit user to cancel. If you want to use a cancellable progress bar, or if you can not prohibit user to do any action, cancel previous requests, using a Boolean isCancelled tracker.

6. Keep track of events like Swipe, Orientation Change, change in size of screen, device resolution adaptation, virtual keyboard show and hide, paused and resumed state of Displayable/MainScreen/Activity. All the recording of screen state should be done in a onPause() callback, and all the refresh activity in onResume().

7. There are design concepts for showing most of the contents in the same screen. Like you have Tabbed Panes, NavigationDrawer, ViewPager, ActionBars, Immersive mode, Context menus, 'SuperFish', 'Carousels', ScrollView and so on in Android. If these are properly implemented, gives user a comfortable experience.