Android Tutorial

(avery) #1
Android Tutorial 373

Finally, from this Runnable object, which runs on a separate
queuing thread, spacing out image drawing, another anonymous
Runnable object posts back to the main thread to actually update
the ImageSwitcher with the new image. Figure shows what the
screen might look like showing decoding status and displaying the
current image.


Screen showing a flickr image and decoding status of feed.


Although all this continues to happen
while the feed from flickr is decoded,
certain operations are slower than others.
For instance, while the image is decoded
or drawn on the screen, you can notice a
distinct hesitation in the progress of the
decoding. This is to be expected on
current mobile devices because most have
only a single thread of execution available
for applications. You need to use careful
design to provide a reasonably smooth and
responsive experience to the user.


Retrieving Android Network Status


The Android SDK provides utilities for gathering information about
the current state of the network. This is useful to determine if a
network connection is even available before trying to use a network
resource. The ConnectivityManager class provides a number of
methods to do this. The following code determines if the mobile

Free download pdf