PA 8001 2013 Practical 4
There are two main objectives for this practical:
- Learn about and use the basic concepts of Android programming
- Understand the concurrency constructs in Android
Submit a single .zip file on blackboard with two folders, each containing the solutions to the below-specified parts. For each application, specify beforehand at least four different test-cases and include them as a comment in your main class. Also for each non-trivial function specify pre- and post-condition and some test-cases. Implementing the test-cases using JUnit will be considered a bonus.
Part 1: ADT Basics: Prime numbers
Install Android SDK (or ADT bundle) from .
Make a new Android project similar to the one created during the lecture and further elaborated at .
Implement the Quitter application described in the lecture. It has a single button and quits the application once the button is pressed. Additionally, it creates logs on the development window for each and every step in the activity lifecycle.
Part 2: Concurrency
Modify it in such a way that in the main activity the use can enter an integer and in the second activity the set of prime numbers up to that integer are displayed (one by one in a text-box, with 1 second delay). If the entered text is not an integer, then an error message should be logged on the developer terminal, a toast notification is displayed and the second activity should not be started.
At any moment the user should be able to stop the calculation and return to the main activity.
Observe the behavior when a large natural number is entered. This is caused by the single-thread model in the application. Separate the threads for calculating next numbers and make UI reactive.