Features of Android
The
detailed features of Android and how to take advantage of them provide a main theme
throughout this book. On a broader level, some key features of Android are
major selling
points and differentiators. It is good to be aware of these strong points of
Android and utilize them as much as
possible.
Multiprocess
and App Widgets
The
Android OS does not restrict the processor to a single application at a
time.The system manages
priorities of applications and threads within a single application.This has the benefit
that background tasks can be run while a user engages the device in a
foreground process.
For example, while a user plays a game, a background process can check stock prices
and trigger an alert as necessary.
App
Widgets are mini applications that can be embedded in other applications (such
as the Home
screen).They can process events, such as start a music stream or update the outside
temperature, while other applications are running.
Multiprocessing
has the benefit of a rich user experience.However, care must be taken to avoid
power-hungry applications that drain the battery.These multiprocess features
are discussed
further in Chapter 3,“Threads, Services, Receivers, and Alerts.”
Touch,
Gestures, and Multitouch
The
touchscreen is an intuitive user interface for a hand-held device. If utilized
well, it can
transcend a need for detailed instructions. After a finger touches the screen,
drags and flings
are natural ways to interact with graphics. Multitouch provides a way to track
more than one
finger down at the same time.This is often used to zoom or rotate a view.
Some
touch events are available transparently to the developer without the need to implement
their detailed behaviors. Custom gestures can be defined as needed. It is important
to try to maintain a consistent usage of touch events as compared to other applications.These
touch events are discussed further in Chapter 5,“User Interface Events.”
Hard
and Soft Keyboards
One
feature on a pocket device that galvanizes users is whether it should have a
physical (also
called hard) keyboard or software (also called soft) keyboard.The tactile
feedback and
definite placement of keys provided by a hard keyboard tends to make typing
much faster
for some, whereas others prefer the sleek design and convenience offered by a
software- only
input device.With the large variety of Android devices available, either type can be
found.A side effect for developers is the need to support both. One downside of
a soft
keyboard is a portion of the screen needs to be dedicated to the input.This
needs to be considered and tested for any
user interface (UI) layout.
Maintaining
Forward Compatibility
New
Android versions are generally additive and forward compatible at the API
level. In fact, a
device can be called an Android device only if it passes compatibly tests with
the Android
APIs. However, if an application makes changes to the underlying system,
compatibility is not
guaranteed.To ensure forward compatibility of an application when future
Android
updates are installed on devices, follow these rules suggested by Google:
- Do not use internal or unsupported APIs.
- Do not directly manipulate settings without asking the user.A future release might constrain settings for security reasons. For instance, it used to be possible for an app to turn on GPS or data roaming by itself, but this is no longer allowed.
- Do not go overboard with layouts.This is rare, but complicated layouts (more than 10 deep or 30 total) can cause crashes.
- Do not make bad hardware assumptions. Not all Android devices have all possible supported hardware. Be sure to check for the hardware needed, and if it does not exist, handle the exception.
- Ensure device orientations do not disrupt the application or result in unpredictable behavior. Screen orientation can be locked, as described in Chapter 2.
Note that
backward compatibility is not guaranteed with Android. It is best to declare the
minimum SDK version as described in Chapter 2, so the device can load the proper compatibility
settings. Utilizing other new features on older targets is also discussed at various places throughout the
book.
0 komentar:
Post a Comment