22. Android application
Review the presentation Android
Tasks
- Download the files
- Set up your Android phone
- Set up your IDE
- Clone and implement the required project
- Create a new repository and push the project
Download the files
Download Android Studio from https://developer.android.com/studio/ and unzip it.
Set up your Android phone
- Open Settings, then tap About device or About phone.
- Scroll down and then tap Build number seven times
- If necessary, enter your pattern, PIN, or password to enable the Developer options menu
- Return to Settings, select the Developer options menu
- Scroll down to Developer options and enable USB debugging
Set up your IDE
Install the Android debugger:
sudo apt-get install android-tools-adb
Set up your SDK and AVD
Set up the SDK
- If necessary, close all projects and open the Welcome to Android Studio window.
- Select Configure — SDK Manager.
- Click Android 12.0 (R), 31,... and click OK.
- Close the SDK Manager window.
Set up the AVD
- If necessary, close all projects and open the Welcome to Android Studio window.
- Select Configure — AVD Manager and click + Create Virtual Device.
- Select Phone, 2.7" QVGA and press Next.
- Select R 31, x86, Android 12 (Google API) and press Next.
- Review the suggested AVD name (the name must include the API version), for example 2.7 QVGA API 31 and press Finish.
- Close the AVD Manager window.
If necessary, create a simple test project
- If necessary, close all projects and open the Welcome to Android Studio window.
- Select Start new Android Studio project.
- Review the suggested names and press Next.
- Select Phone and Tablet and select API 31: Android 12 (R) and press Next.
- Select Basic Activity and press Next.
- Review the suggested names and press Finish.
Run a simple test project if necessary
- If necessary, verify that you have opened your test project.
- Select the Run — Run... menu.
- Select MainActivity.
- Select the 2.7 QVGA API 31 virtual machine and press OK.
- Verify that the application is working correctly (i.e., a pop-up menu appears when you click on the envelope).
Clone and implement the required project
Clone the git repository:
cd ~/AndroidStudioProjects
git clone https://odo.lv/git/Android_Test AndroidChange the settings files:
app/src/main/res/values/strings.xml in the file change line:
...
<string name="app_name">XXXXXX</string>
...where XXXXXX is your identifier
app/build.gradle in the file change line:
...
applicationId "jtm.xxxxxxx"
...where xxxxxxx is your project code in lowercase (because by convention Java packages only have lowercase letters).
(On the Android Studio home screen select Import project (Gradle, Eclipse ADT, etc.)
- Select the Android project and press OK.
- Review the warnings and suggested fixes if the project needs to be rebuilt.
- Implement the application class jtm.android.MainActivity.java so that the user can change the background color of the screen using sliders that represent RGB colors.
- Select the menu app — java — org.jtm — MainActivity,
- Write your code in the required parts of the MainActivity.java file.
- Verify that the unit tests are successful:
- Select the menu app — java — jtm.android — JUnitTest — for testing JUnit unit tests,
- Select the menu app — java — jtm.android — AndroidTest — for testing the Android system (graphical interface)
- Modify the existing remote repository entry or add a new remote repository entry tools.odo.lv
Create a new repository and push the project
- If necessary, review the exercise 1. Java darbstacijas sagatavošana
- Create a folder Android in your user folder at tools.odo.lv, and create a bare git repository in it
- Create a new or replace the existing repository entry to ssh://XXXXXX@tools.odo.lv/home/students/XXXXXX/Android/, where XXXXXX is your student ID
- Push the change to the above repository
Additional information
- http://developer.android.com/reference/packages.html including:
- SeekBar.OnSeekBarChangeListener class
- Color class
- Change background color, by SeekBar
- https://developer.android.com/training/testing/fundamentals.html
- https://developer.android.com