ITCS5180 -concurrency-IC4 solved

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

In this assignment you will get familiar with Android concurrency models. This

 

Select Complexity :                            8 Times

Minimum:

Maximum:

Average:

 

Select Complexity :                 8 Times
 

Select Complexity :                            8 Times

Minimum:               0.23789596

Maximum:              0.81256734

Average:                 0.51235723

(a) Launching screen (b) Progress Bar (c) Display
Figure 1, App User Interface  

application is composed of a single activity: Main Activity.

The interface should be created to match the user interface (UI) presented in Figure 1. You will be using layout files, and strings.xml to create the user interface. Perform the following tasks:

  1. Create a new android project called “In Class 4”.
  2. You are provided with a HeavyWork class that contains a static method getArrayNumbers( int n). This method takes a long time to execute. Import the provided Java file by simply dragging the file into the src folder under your project package.
  3. Your task is to use an AsyncTask to execute this method in a background thread. Do not use the main thread to generate the numbers. The UI should be manipulated by the only main thread.
  4. Use a SeekBar to set the complexity of the heavy work. The SeekBar maximum should be set to 10. Also note, the TextView showing the selected complexity number which is displayed to the right of the “Select Complexity” label, this number should be updated whenever the user moves the SeekBar. The selected number defines the number n of getArrayNumbers( int n) method in the background AsyncTask.
  5. Tapping on the “Generate Number AsyncTask” button should start the execution of a background AsyncTask and compute the minimum, maximum, and average of all the numbers returned as an ArrayList by the getArrayNumbers() method. For example, if the complexity was set to 5, the getArrayNumbers() method will return an ArrayList of 5 numbers. The minimum, maximum, and average of these 5 numbers should be computed and displayed in the TextViews. While these numbers are being generated, display a ProgressBar indicating the progress, see Figure1(b). The ProgressBar should be dismissed automatically after the computation is completed and the numbers generated and displayed in the TextViews, see Figure 1(c).

Homework part: Using Threads and Handlers

This part is similar to in class 04, but you should use threads and handlers to implement the same functionality. Perform the following tasks:

  1. You should create a thread pool of size 2. Use the thread pool to execute the created thread.
  2. Tapping on the “Generate Number Thread” (in stead of “Generate Number AsyncTask”) button should start the execution of a background thread and compute the ArrayList (based on the selected complexity) returned by the getArrayNumbers( int n) method, as done in the in-class assignment.
  3. To be able to exchange messages between the child thread and the main thread use the Handler class. Either use messaging or setup a runnable message.
  • Android-concurrency-IC4_2a-hcgdve.zip