Android How to Program Chapter 12 Solution Manual
Download file with the answers
Android How to Program Chapter 12 Solution Manual
1 file(s) 267.89 KB
If you are not a member register here to download this file
12 Slideshow App
Objec t ives
In this chapter you’ll:
■ Use Intents and content
providers to allow the user to
select pictures and music
from a device’s Gallery and
media library, respectively.
■ Launch Intents that return
results.
■ Use a MediaPlayer to play
music from the device’s
media library during the
slideshow.
■ Customize a
ListActivity’s layout.
■ Use the view holder pattern
to improve performance
when using complex
ListView-item layouts.
■ Create a custom GUI for an
AlertDialog to allow a
user to enter information,
■ Load images as Bitmaps
using a BitmapFactory.
■ Use a
TransitionDrawable to
gradually transition between
two BitmapDrawables
that contain images.
Self-Review Exercises 2
Self-Review Exercises
12.1 Fill in the blanks in each of the following statements:
a) Activity method enables an Activity to be notified when another Activity
completes execution and to receive results back from the completed Activity.
b) When the ArrayAdapter’s data set changes, you can call its method to indicate
that the Adapter’s underlying data set has changed.
c) You images to save memory; This helps prevent out-of-memory errors,
which can be common when manipulating many Bitmaps.
d) Intent with Intent’s ACTION_GET_CONTENT constant indicates that the Intent allows
the user to select content that’s stored .
e) An Intent that uses the MIME type ” ” to allows the user to select any type
of audio on the device.
f) Method prepare will if the MediaPlayer cannot be prepared—for example,
if it’s currently playing a media clip.
g) Calling MediaPlayer’s method moves the audio playback to the specified
time in milliseconds.
12.2 State whether each of the following is true or false. If false, explain why.
a) (True/False) Several BroadcastReceivers are built into Android for access to data such
as images, audio, video, contact information and more.
ANS: False. Several content providers are built into Android for access to data such as images,
audio, video, contact information and more.
b) (True/False) Setting the android:singleLine attribute to false allows only a single line
of text in an element.
Exercises
12.3 Fill in the blanks in each of the following statements:
a) Android uses that enable apps to save and retrieve data and to make data
accessible across applications.
b) When you scroll in a ListView, as items scroll off the screen, Android reuses those list
items for the new ones that are scrolling onto the screen. You can take advantage of the
existing GUI components in the reused list items to increase a ListView’s performance
of your ListViews. To do this, use the pattern.
c) A (package android.graphics) creates Bitmap objects.
d) In general, you should wrap calls to startActivity and startActivityForResult in a
try statement, so you can catch the exception if there is no Activity to handle the
.
3 Chapter 12 Slideshow App
e) State information is saved in onSaveInstanceState and loaded in when
the Activity goes to the background and returns to the foreground, respectively.
12.4 State whether each of the following is true or false. If false, explain why.
a) (True/False) Creating custom ListView items is a cost effective runtime operation, even
for large lists with complex list-item layouts.
b) (True/False) Method onActivityResult is called when a sub-Activity started by the
startActivityForResult method finishes executing.
c) (True/False) Calling MediaPlayer’s setLooping method with the argument true loops
playback if the music’s duration is longer than the total slideshow duration.
if the music’s duration is shorter than the total slideshow duration.
d) (True/False) Use the view-holder pattern to boost the performance of ListViews with
complex list-item layouts.
Leave a reply