Create a Android Game App

Objective:

The game implemented from Assignment #1 is improved with a menu, settings, statistics kept in a database, themes, animations, and asynchronous behaviour (timer-based actions and notifications).

While some of the timer-based actions and notifications employed in this application generally might annoy a user, they are included in the assignment for the purposes of learning how to implement these features.

Specifications:

  • Create a “dark theme”
    • The window’s background colour (android:windowBackground) should be black (or other dark colour)
  • The menu item’s background colour (android:itemBackground) should be the same as the window’s background colour

Get a free copy of this project Contact AssignmentHelp

Create a Android Game App

    • The foreground text (android:textColor) should be white (or other light colour)
    • The theme can be set via Preferences from the Settings fragment (see specification below)
  • Track the win/loss statistics in an SQLite database
    • Keep track of the timestamp every game was played and the result of the game in a table. You may consider storing the integer value of seconds from epoch for the timestamp, e.g.: Math.round(System.currentTimeMillis() / 1000)
    • The statistics can be viewed and reset via a new activity launched through the menu (see specification below)
  • Implement a menu for the Action Bar with two entries when clicked, starts the following activities
    • Settings: a settings activity for Preferences
      • Show a back button in the Action bar that goes back to the game screen
      • Show a switch preference for saving and displaying the results of the most recently played game when the app is fully closed and reopened
        • When the preference is turned off, fully closing the app and reopening it will start with the UI not showing the last game’s results and images (see how the starting point the text and images in the activity should be in from Assignment #1)
        • When the preference is turned on, fully closing the app and reopening it will show the results and images from the last game (same behaviour as rotating the screen and deactivating/reactivating the app)
      • Show a switch preference that toggles between the dark theme and the light theme
        • Ensure your setTheme calls in all your activities’ onCreate method adheres to the saved preference’s value (e.g., when bringing up Stats activity, you can pass the theme preference value by Intent from Main Activity, or get the value via Preferences)
        • You may want to override onRestart to restart the MainActivity if the theme has changed to call onCreate and its setTheme with the new value. You can restart an activity by calling these two lines of code inside of the activity you wish to restart:

finis();

startActivity(getIntent());

    • Statistics: a non-launcher activity (you may wish for this class to extend AppCompatActivity, just like how your MainActivity class inherits from AppCompatActivity) with the following:
      • Show a back button in the Action bar that goes back to the game screen
      • Retrieve data from the SQLite database and then display:
        • Win/loss record for all games in the past minute
        • Win/loss record for all games since the beginning or when the stats were last reset
      • Show a button that when tapped, resets the statistics (deletes all past games stored in the database table) — the statistics currently displayed on the screen should also refresh to reflect the reset database
      • You may wish to employ the use of an application object so that on app start, the database tables are created, and the resulting database instance can be accessed by both your main activity and your statistics activity
  • Animate the results of the game by having the images fade into the screen as shown in the video. Only update the text that summarizes the results of the game (e.g., “you won”, etc.) after the animation is complete.
  • After the end of any game, if the user has not started a new game after 3 seconds, display a toast that encourages the user to keep playing.
  • Create a service for the application that sends a notification after 10 seconds on your application’s onCreate method to the mobile user to encourage him/her to keep playing. The notification should appear after the delay even if the application is not running in the foreground. When the notification is tapped, it should launch the application.