## Chapter 1. Intro to Android App Development Course with Kotlin & Java | Android Terms: 1. **SDK**: Software Development Kit 2. **APK**: Android Package Related project files: 1. [android-app-development-with-kotlin](https://github.com/OakAcademy/android-app-development-with-kotlin) 2. [math-game-according-to-three-game-activity-with-kotlin](https://github.com/OakAcademy/math-game-according-to-three-game-activity-with-kotlin) 3. [math-game-with-one-game-activity](https://github.com/OakAcademy/math-game-with-one-game-activity) ## Chapter 2. Environment Setup for Android Course Terms: 1. **JDK**: Java Development Kit, which is a software development environment for Java, containing JRE and other development tools(compiler, debugger, etc.). 2. **JRE**: Java Runtime Machine. JRE contains JVM and Java libraries. 3. **JVM**: Java Virtual Machine, which runs the Java code. ## Chapter 3. Android Studio Interface **Gradle Build System** - Gradle is a building system for Android development. - Gradle Supports compiling, running, debugging, and publishing on Google Play. - build.gradle (project) shows the Gradle version. - build.gradle (module) shows the expected SDK version and the version name of the app, and the libraries needed in *depedencies*. **Android Manifest File** - Android manifest file is an .xml file, containing important informations about the app. - It contains the app name, app icon, user permissions, display, etc. ## Chapter 4. Android Components [Layouts Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap4_Layouts_Example) [UI elements Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap4_Components_Example) **Layouts** - The layouts determine the structure of user interface. - There are 4 kinds of layouts: *linear*, *relative*, *table*, and *constraint*. ### Linear Layouts The property **android:orientation** shows how the components are arranged one by one. From top to bottom if *vertical*, from left to right if *horizontal*. ![](https://hackmd.io/_uploads/Hkn2Gap_h.png) ### Relative Layout The components under the layout are arranged by relativities, defined in the components' properties, e.g. *layout_centerHorizontal*, *layout_above*, etc. ![](https://hackmd.io/_uploads/H1hHMaaun.png) ### Table Layout The components under the layout are arranged in rows and columns, using the **TableRow** components. ![](https://hackmd.io/_uploads/HkdHL6adn.png) ### Constraint Layout A constraint layout works similarly to relative layout; however, constraint layout is more complicated but flexible than relative layout. ![](https://hackmd.io/_uploads/ByWXPgeF3.png) ### TextView A TextView is a component that can hold texts. ### Button A Button is a component that users can click, and we use the method **setOnClickListener** to handle the click's effect. ### EditText An EditText is a bar that user can enter something in. There are several types of it, for example, *Plain Text*, *Password*, *Password(Numeric)*, *Multiline*, etc. ### ImageView An ImageView is a component that holds an image. ### CheckBox A CheckBox is a component that user can check in the given box as information to the app. You can use the property **isChecked** to know whether the CheckBox is checked. ### RadioButton A RadioButton looks simliar to a series of CheckBox, the user should choose one of them. You should wrap the RadioButtons using the component **RadioGroup**. ### ToggleButton A ToggleButton is a button which has 2 states, on and off. You can specify the text shown by modifying the properties **textOn** and **textOff**. ToggleButtons don't use *setOnClickListener* to handle the toggle, they use **setOnCheckedChangeListener** instead. ### Spinner A Spinner is a dropdown list, which you can choose one option among it. To give the options, you should use **ArrayAdapter**. ![](https://hackmd.io/_uploads/HkcLkIIth.png) ![](https://hackmd.io/_uploads/r1yJeUIKh.png) ### Useful developing functions ![](https://hackmd.io/_uploads/BJSsaPGY3.png) Left: *Clear Constraints*: Clear all constraints of the selected component Right: *Infer Constraints*: Auto-complete the constraints using the current position of the component. ## Chapter 5. User Interactions in Android App Development [Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap5_Example) ### Toast A Toast contains some message for the user and disappear after a short period of time. ![](https://hackmd.io/_uploads/SJ1DjI8t2.png) ### Snackbar A Snackbar is similar to Toast; however, the user can close the message by clicking the "Close" button. ![](https://hackmd.io/_uploads/HJbfo8LY2.png) ### Dialog Message A Dialog Message is a message block that gives user operations to choose (for example, "Yes" or "No"). ![](https://hackmd.io/_uploads/S1Rss88tn.png) ## Chapter 6. Lists & Views in Android ### ListView A ListView is a view that contains several elements in the screen vertically, and ListView is scrollable if the length of the list exceeds the screen. [ListView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap6_ListView_Example) ![](https://hackmd.io/_uploads/BJgsC4qFh.png) ### RecyclerView A RecyclerView is an advanced version of ListView. It can contain more information then ListView does. [RecyclerView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap6_RecyclerView_Example) ![](https://hackmd.io/_uploads/rkawIE5Kn.png) ### GridView A GridView is a 2-dimensional layout that displays the content in columns and rows. [GridView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap6_GridView_Example) ![](https://hackmd.io/_uploads/HyVgDeoFh.png) ### ScrollView A ScrollView is a view which is used when the content is too long so scrolling is needed. The scrollbar will not appear if it is unnecessary. [ScrollView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap6_ScrollView_Example) ![](https://hackmd.io/_uploads/ByEoG9iF3.png) ### WebView A WebView is a view that allows Android OS to display content from web. It also needs Internet and Wi-Fi permission from the user. [WebView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap6_WebView_Example) ![](https://hackmd.io/_uploads/HyQ5Vlnt2.png) ### Differences between Layouts and Views *Layouts* define the structure and arrangements of the views on the screen, and *views* define the actual position of the UI elements (e.g. TextView, buttons, etc.) ### Adapter An Adapter is a connecting component between data sources and user interface. It is used to display and manipulate data in the UI. ## Chapter 7. Intent and Lifecycles [Lifecycle and Service Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap7_Lifecycle_Service_Example) ### Intent An Intent is an object that provides runtime binding between separate components, for example, between two activities. It can also be used to transfer data between components. If we want to build connection between two activities, we need to change the property **android:parentActivityName** of the child activity in AndroidManifest.xml. ### Application Lifecycle ![](https://hackmd.io/_uploads/Bk8G246t2.png) There are 3 methods that runs when the application starts: **onCreate()**, **onStart()**, and **onResume()**, one by one. The onResume() method continues as long as the application is running. The **onPause()** method is called when the application is interrupted by the Android OS, for example, a phone call or a message. In this case, the onResume() method is paused; after the interruption ends, the onResume() method starts working again. The **onStop()** method is employed when the user leaves the application. If the user comes back, then the **onRestart()**, onStart(), and onResume() methods are employed on after another. If the application is closed, then the **onDestroy()** method is called to terminate the application. If the user jumps from the current application to another application, the current applcation will process onPause() and onStop() methods. If the user doesn't come back, then the onDestroy() method is automatically called by the system. ### Activity Lifecycle The lifecycle of the activity is pretty much similar to that of the application. If the user jumps from Activity A to Activity B, then the methods will execute in the following order: ```kotlin= ActivityA.onPause() ActivityB.onCreate() ActivityB.onStart() ActivityB.onResume() ActicityA.onStop() ``` If the user rotates the device when Activity A is executing, then the methods will execute in the following order: ```kotlin= ActivityA.onPause() ActivityA.onStop() ActivityA.onDestroy() ActivityA.onCreate() ActivityA.onStart() ActivityA.onResume() ``` In the above examples, the data stored in ActivityA.onResume() might be flushed since ActivityA is recreated. ### Fragment Lifecycle ![](https://hackmd.io/_uploads/HkT_RcMch.png) A Fragment is a more useful and dynamic interface for the users. You can use a **FragmentContainerView** to display it in a certain segment in the UI. ### Service A Service is an application component performing long-running operations in the background. Since it is not used to interact with the user, it is not visible in the UI. A Service can be started by another application component. Therer are 3 kinds of services: **foreground services**, **background services**, and **bound services**. A *foreground service* lets the user to see the application process in some form of notifications. A *background service* in the other hand, won't show any notification or message to the user. It can be used when the process is not so important for the user to know how is it processed. A *bound service* is a service that is bound to another application component. Since the service interacts with the component calling the service, it does not run in the background. Traditionally, there are 2 service classes: **(standard)service classes** and **jon intent service classes**. A *(standard) service class* is a normal service class that takes the fixed ratio of storage in the device, which means it's good to use it if the application is small, but not if the application is big since it could be slow. A *job intent service class* in the other hand, does not have the tendency to slow down the application, so it is used for long-term background process. ### Broadcast Receiver A broadcast message is sent when an event of interest occurs, e.g. device charging, system boot, etc. When a broadcast is sent, the system routes broadcast to apps that have subscribed the particular type of broadcast. ### Android View Binding [View binding Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap7_viewBinding_Example) View binding is a new way to connect the component in the UI to the code. We need to add some code to our build.gradle(Module): ```gradle= android { buildFeatures{ viewBinding = true } } ``` ## Chapter 8. SharedPreference and Data Sharing ### SharedPreference [Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning/tree/Chap8_Example) A SharedPreference allows the developer to save and retrieve data in a form of key-value pair. The data is stored in the local storage of the device, and we can store the data using the **editor**. ## Chapter 9. Device Compatability in android 12 app development [Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap9_Example) ### Multiple Language Support 1. Make sure that all the strings to display are in string.xml, or some of them will not be translatable. 2. Open translations editor. ![](https://hackmd.io/_uploads/r1gNh7V92.png) 3. Add the language you want to translate. ![](https://hackmd.io/_uploads/rk7qhmN9n.png) 4. Enter the translated data. ![](https://hackmd.io/_uploads/HyOJ67Vcn.png) 5. Change the default language of the virtual device in Settings. 6. Restart the application. ### Support different pixel density It is necessary to give different resolution images so that in different devices, the images won't be blurred or blocked. You can use the Android Asset Studio to generate 5 different resolutions and put it into the project. [Android Asset Studio](https://romannurik.github.io/AndroidAssetStudio/nine-patches.html#&sourceDensity=320&name=example) ![](https://hackmd.io/_uploads/HkvMn6492.png) ### Support different screen size For supporting different screen size: 1. Add a new layout to the layout folder. ![](https://hackmd.io/_uploads/rynOVlrqn.png) 2. Select the "Size" qualifier. ![](https://hackmd.io/_uploads/r1SkBgS5h.png) 3. Select the size of the layout and give the file name. ![](https://hackmd.io/_uploads/BJfHHeBcn.png) :::info The file name should be exactly the same to the activity you want to implement in different screen size. ::: For supporting different screen orientation: 2. Select the "Orientation" qualifier. ![](https://hackmd.io/_uploads/HJNNUxr52.png) 3. Select the orientation of the layout and give the file name. ![](https://hackmd.io/_uploads/SkBP8eS53.png) ## Chapter 10. Android Project 1 - Kotlin [TodoList Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap10_TodoList) ## Chapter 11. Android Project 2 - Kotlin [Math Game Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap11_Math_Game) ## Chapter 12. Introduction to Android App Development Course with Java :::info This part is highly identical to the previous lesson, so no note is taken in this chapter. ::: ## Chapter 13. Android Studio Interface :::info This part is highly identical to the previous lesson, so no note is taken in this chapter. ::: ## Chapter 14. Components of Android [Layouts Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap14_Layouts_Example) [Components Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap14_Components_Example) The xml code of a Java project is same as that of a Kotlin project, so the only difference is in the MainActivity file. There are some slight differences between MainActivity.kt and MainActivity.java. For example, for the component declaration: ```java= // Kotlin side lateinit var myText: TextView // Java side TextView myText; // Remember to add semicolon ``` For the click listener: ```java= // Kotlin side myButton.setOnClickListener { // Your code here } // Java side // You can use auto-complete to deal with the code. myButton.setOnClickListener(new View.onClickListener { @override public void onClick (View v) { // Your code here } }); ``` ## Chapter 15. User Interactions [Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap15_Example) ## Chapter 16. Lists & Views [ListView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap16_ListView_Example) [RecyclerView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap16_RecyclerView_Example) [GridView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap16_GridView_Example) :::info The sample code of ScrollView is exactly the same as that of Kotlin. ::: [WebView Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap16_WebView_Example) ## Chapter 17. Components and Lifecycles [Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap17_Example) ## Chapter 18. Shared Preferences and Data Sharing [Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap18_Example) ## Chapter 19. Device Compatability [Sample Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap19_Example) ## Chapter 20. Android Project 1 [TodoList Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap20_TodoList) ## Chapter 21. Publishing Your App on Google Play ### Version code Version code is a positive integer as an internal version number. The greatest valid version code that Google Play allows is 2,100,000,000. ### Version name Version name is a version number in string that is shown to the user. You can check both values in android.defaultConfig of build.gradle(module). ![](https://hackmd.io/_uploads/ryJdb4Qo2.png) ### How to create an App Bundle 1. Choose Build->Generate Signed Bundle/APK in the top toolbar. 2. Choose "Android App Bundle" option. ![](https://hackmd.io/_uploads/H1x9zrmi3.png) 3. If no key store existing, create a new one. 4. Give the necessary passwords. ![](https://hackmd.io/_uploads/SJZ0MrQo3.png) 5. Select "debug" or "release" and click "Create". ![](https://hackmd.io/_uploads/Hkbx7HQs3.png) ### How to release your app 1. Create an APK file using Android Studio. 2. Register and login a Google Developer Account. 3. Go to the Google Play Console and click "CREATE APPLICATION", then give the default language and the title of your app and click "CREATE". 4. Give all necessary information of your app in the *"Store listing"* tag and click "SAVE DRAFT". 5. Upload your APK file in the *"App Releases"* tag. Make sure your package name **DOES NOT** contain "com.example". 6. Check the release name and description and click "SAVE". 7. Go to the *"Content Rating"* tag and give your email and the category of your app, then confirm some information according to the category, e.g. violence, sexuality, racism, etc. and click "APPLY RATING". 8. Go to the *"Pricing & Distribution"* tag and give the pricing state(free/paid), the available countries, whether the app contains ads, and the other consents. 9. Go to the *"App Content"* tag, give the target age group(you need to add some policies if you choose groups under 18) and select whether the app will be shown to children. 10. Go to the "App Releases" tag and click "EDIT RELEASE"->"REVIEW"->"START ROLL-OUT TO PRODUCTION", then the app will be published. ## Chapter 22. Android Project 2 [Math Game Code](https://github.com/guavaaa0826/Logos_Lab_Self-learning-Android-App-Development/tree/Chap22_Math_Game)