Q1. Media files (such as the sounds we used in the Cannon Game app), are
placed in the app’s resource folder ________.
1. res/media
2. res/sounds
3. res/raw
4. res/multimedia
Answer: c. res/raw
Activity and Frag
...
Q1. Media files (such as the sounds we used in the Cannon Game app), are
placed in the app’s resource folder ________.
1. res/media
2. res/sounds
3. res/raw
4. res/multimedia
Answer: c. res/raw
Activity and Fragment Lifecycle Methods
Q1. Which of the following statements is false?
1. When an Activity is shut down, its onDestroy method is called, which in
turn calls the onDestroy methods of all the Fragments hosted by the
Activity.
2. We used the onDestroy method in the MainActivityFragment to release
the CannonView’s sound resources.
3. Method onDestroy is guaranteed to be called, so it can be used to
release resources and to save critical data.
4. The Android documentation recommends that you save data in methods
onPause or onSaveInstanceState.
Answer: c. Method onDestroy is guaranteed to be called, so it can be used to
release resources and to save critical data. Actually, method onDestroy is not
guaranteed to be called, so it should be used only to release resources, not to
save critical data.
Overriding View Method onTouchEvent
Q1. To process simple touch events in an app, override View method
onTouchEvent, then use constants from class ________ (package
android.view) to test which type of event occurred and process it accordingly.
1. Event
2. MotionEvent
3. Motion
4. View
Answer: b. MotionEvent
Adding Sound with SoundPool and AudioManager
Q1. An app’s sound effects are managed with a(n) ________ (package
android.media), which can be used to load, play and unload sounds.
1. Effects
2. SoundPool
3. EffectsPool
4. SoundManager
Answer: SoundPool
Q2. Sounds are played using one of Android’s audio- ________ for alarms,
music, notifications, phone rings, system sounds, phone calls and more.
1. streams
2. players
3. tools
4. None of the above
Answer: a. streams
Q3. The Android documentation recommends that games use the ________
to play sounds, because that stream’s volume can be controlled via the
device’s volume buttons.
1. phone audio stream
2. alarm audio stream
3. notifications audio stream
4. music audio stream
Answer: d. music audio stream
Q4. Which of the following statements is false?
1. You configure and create a SoundPool object using a
SoundPool.Builder object.
2. You use an AudioAttributes.Builder object to create an AudioAttributes
object that will be associated with the SoundPool.
3. AudioAttributes’s setGameAudio method is used to designate the audio
as game audio.
4. Activity’s setVolumeControlStream method allows the game’s volume to
be controlled with the device’s volume buttons.
Answer: c. AudioAttributes’s setGameAudio method is used to designate the
audio as game audio. Actually, AudioAttributes’s setUsage method is used to
designate the audio as game audio.
Frame-by-Frame Animation with Threads, SurfaceView and
SurfaceHolder
[Show More]