59.8 Modifying the User Interface
As will become evident when the application runs, failing to create a new thread for the service to perform tasks creates a serious usability problem. In order to be able to appreciate fully the magnitude of this issue, it is going to be necessary to add a Button view to the user interface of the MainActivity and configure it to call a method when “clicked” by the user.
Locate and load the activity_main.xml file in the Project tool window (app -> res -> layout -> activity_main.xml). Delete the TextView and add a Button view to the layout. Select the new button, change the text to read “Start Service” and extract the string to a resource named start_service.
With the new Button still selected, locate the onClick property in the Attributes panel and assign to it a method named buttonClick.
Next, edit the MainActivity.java file to add the buttonClick() method and remove the code from the onCreate() method...