Java Reference
In-Depth Information
to initialize the heavier-to-load MenuView . Once loading is complete,
the thread sets the current screen to MenuView .
The event dispatcher thread calls our event handlers, such as command-
Action() , keyPressed() ,and pointerDragged() . Again, the rule
is never to perform blocking operations inside event-handling methods. It
is a common mistake to try to open a connection or do UI construction
work inside a commandAction . Consider, for example, that opening an
HTTP connection could prevent the user from any interaction with our
application until the connection is open. The worst-case scenario is that an
opening connection hangs due to a brokenDNS record or an incapacitated
server. The user is at the mercy of some timeout that we can only hope
exists in theHTTP implementation. Notice how simple and quick our event
handlers are in the previous example showing how to handle both key and
pointer events.
The painter thread is equally sensitive, however it is a very unlikely
place to do any blocking operation with a potential to run for a long time.
Most of the time, painting is carefully scrutinized for other reasons, so we
normally don't expect blocking here.
9.1.3 Increasing Resilience
In a mobile environment, our MIDlet may be interrupted at any point
in time. Typical reasons are an incoming call, a low-battery warning
or loss of network connectivity. Handling these situations correctly is
very important for the user experience. Some level of resilience can be
achieved by expecting failures and handling unexpected errors gracefully.
A more thorough approach could include carefully managing application
state in the case of errors.
9.2 Good Programming Practices
9.2.1 Consider Hardware Limitations
At the time of writing, the Nokia N96 has just been released. It is one of
the most powerful smartphones based on Symbian OS: it has a dual CPU
ARM 9 processor running at 264MHz, 128MB of RAM and 16GB of
user storage memory. Several Symbian OS smartphones have support for
VoIP, multiple media formats, 5 megapixel cameras, and GPS technology,
among others. This is a remarkable evolution, considering that only four
years ago Nokia's flagship 6600 was not capable of even playing MP3
files.
All this is great news for us as Java ME developers, since applications
developed in it can be richer in features, cover more use cases and replace
native application development in many scenarios. However, you should
Search WWH ::




Custom Search