- Learn how the lifecycle of fragment and activity works.
- Learn how to handle configuration change(rotation, keyboard hidden...)
- Implements a simple game that counts how many times a person can tap in 10sec.
- Checkout the skeleton code at: https://github.com/jupitervn/Android_HowFastAreYou
- The UI should look like these below screenshots:
Default portrait layout
Default landscape layout
Gaming portrait layout
Gaming landscape layout
-
The UI contains 2 parts: game part and the high score part.
-
The count should be updated when user presses
TAP
button. -
TAP
button should be disabled until user pressesSTART
. -
After press
START
,START
button is disabled whileTAP
button is enabled. -
After 10sec, the
TAP
button will be disabled and the result will be updated in the high score panel. -
The highscore panel should be implemented inside
TapCountResultFragment
a fragment. -
If user rotates the phone(or press
HOME
):- While a game is playing (clock is ticking) then that game should be paused and
START
button becomesRESUME
button. After user pressesRESUME
, the game will continue. - If a game has stopped then the last tap count should be preserved.
- While a game is playing (clock is ticking) then that game should be paused and
-
Highscore list must be preserved even if user rotates the phone (or presses
HOME
).
- Activity lifecycle: http://developer.android.com/reference/android/app/Activity.html
- Fragment lifecycle: http://developer.android.com/reference/android/app/Fragment.html
- Complete diagram of activity and fragment lifecycle https://github.com/xxv/android-lifecycle
- How to handle configuration change: http://developer.android.com/guide/topics/resources/runtime-changes.html
- Comunicate between activity and fragment: http://developer.android.com/training/basics/fragments/communicating.html
- Log all activities and fragments lifecycle event to see how everything works.
- What is
setRetainInstance()
and how does it affect the fragment lifecycle.