Which programming language would you find in the ‘sdk’ tab of the collection point?
Android is an Operating System for mobile devices developed by Google in 2007, which is built upon a Linux kernel. Android competes with Apple's iOS (for iPhone/iPad), Microsoft's Windows Phone, and many other proprietary mobile OSes. The latest Android supports Phone/Tablet, TV, Wear (watch and glass), Automobile and Internet of things (IoT). Android PlatformAndroid is based on Linux with a set of native core C/C++ libraries. Android applications are written in Java. However, they run on Android's own Java Virtual Machine, called Dalvik Virtual Machine (DVM) (instead of JDK's JVM) which is optimized to operate on the small and mobile devices. In May 2017, Google announced support for a new Kotlin programming language. As you are familiar with Java, you probably should start in Java (many of the examples out there are written in Java), and then move into Kotlin. Kotlin will not be discussed in this article. The mother site for Android is https://www.android.com. For programmers and developers, visit https://developer.android.com to download the SDK, Android Training, API Guides and API documentation. Installing "Android Studio IDE" and "Android SDK"Installing Android software is probably the most challenging part of this project. It takes times - from 30 minutes to n hours to forever - depending on your luck, your programming knowledge, and your PC. You probably need a fairly decent PC (with 8GB RAM) and 10GB of free disk space to run the Android emulator!!! Running on "actual" Android phone/tablet requires much lesser resources. Step 0: Pre-Installation Check List
Step 1: Install "Android Studio IDE"Reference: "Install Android Studio" @ https://developer.android.com/studio/install. (For Windows)
by default, the "Android Studio IDE" will be installed in " // For macOS cd ~/Library/Android/sdk/tools ./android avd // For Windows cd C:\Users\your-username\AppData\Local\Android\sdk\tools android avd1", and the "Android SDK" in " // For macOS cd ~/Library/Android/sdk/tools ./android avd // For Windows cd C:\Users\your-username\AppData\Local\Android\sdk\tools android avd3". Notes (SKIP): You can also use the ZIP version: Download the Windows 64-bit ZIP version (about 1.5GB) ⇒ UNZIP into a folder of your choice ⇒ Run " // For macOS cd ~/Library/Android/sdk/tools ./android avd // For Windows cd C:\Users\your-username\AppData\Local\Android\sdk\tools android avd4" to launch the Android Studio ⇒ It will enter the "setup" for the first launch ⇒ "Do not Import Settings" ⇒ In "Welcome", click "Next" ⇒ In "Install Type", choose "Custom" (so that you can see what is going on) ⇒ In "Select Default JDK Location", use default ⇒ In "Select UI Theme", choose one that you like ⇒ In "SDK Components Setup", select "Android Virtual Device (1.05GB) ⇒ Take note of the "Android SDK Location" with default of " // For macOS cd ~/Library/Android/sdk/tools ./android avd // For Windows cd C:\Users\your-username\AppData\Local\Android\sdk\tools android avd5" ⇒ In "Emulator Settings", use default ⇒ In "Verify Settings", check the settings and choose "Finish" ⇒ In "Download Components", click "Details" and check that nothing fails ⇒ Wait ⇒ Wait ⇒ Wait. (For macOS)
The "Android SDK" will be installed in " // For macOS cd ~/Library/Android/sdk/tools ./android avd // For Windows cd C:\Users\your-username\AppData\Local\Android\sdk\tools android avd7", where ~ denotes your home directory. Note: If you see a warning that says "the package is damaged and should be moved to the trash", goto "System Preferences" ⇒ Security & Privacy ⇒ under "Allow applications downloaded from" ⇒ select "Anywhere". Then run again. Step 2: Installing Android SDKThis step takes a long time as you need to download about 3GB of zip data, and expand to 5 GB of disk data, even for the minimum configuration. Note: You can actually copy the SDK from another computer with the same OS. (For Windows and macOS)
Write your First Android AppAndroid apps are written in Java (or Kotin), and use XML extensively. I shall assume that you have basic knowledge of Java and XML. Take note that Android emulator is slow - VERY VERY VERY SLOW!!! Be Patient!!! Hello-WorldStep 0: ReadGoto "Android Guides" @ https://developer.android.com/guide/index.html. Read "Build your first app". Step 1: Create a New Android Project
Step 2: Setup Emulator (aka Android Virtual Device or AVD)Reference: "Create and manage virtual devices" @ https://developer.android.com/studio/run/managing-avds Note: The older versions of Android Studio called the "emulator" "Android Virtual Device" or "AVD". To run your Android app under an emulator, you need to first create an Android Virtual Devices (AVD). An AVD emulates a specific mobile device (e.g., your zPone 38 or Taimi Green).
Step 3: Run the Android App on Emulator
Common Errors:
Step 4: Run the App on Real Android PhonesReference: "Run on Real Device" @ . To run the Android app on a REAL device (Android Phone or Tablet):
Deleting a ProjectTo delete a project, select "File" ⇒ "Close Project" ⇒ On the "Recent Projects" ⇒ Hover over the project ⇒ Press "Delete" key on the project to remove the project from Android Studio ⇒ You can then delete the project directory from the file system. Hello-world "by Coding"There are two ways to create User Interface (UI) on Android:
Let's begin with writing Java codes (because you have learned Java). We shall continue from the "Hello Android" project created earlier. MainActivity.javaExpand the " "Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" />7" node (by clicking on the triangle). Expand the " "Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" />8" node. Expand the " "Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" />9" package node. Open the " Hello Android XML Hello world from XML!0" (which actually has already been opened). REPLACE the Hello Android XML Hello world from XML!1 method as follows and add the import statement. Do not touch the rest of the codes, if any. Run the application ("Run" ⇒ "Run app"). You shall see the message "Hello, from my Java code!" displayed. Dissecting the "MainActivity.java" - Application, Activity & ViewAn Android application could have one or more Hello Android XML Hello world from XML!2. An Hello Android XML Hello world from XML!2, which usually has a screen, is a single, focused thing that the user can interact with the application (hence called activity). The Hello Android XML Hello world from XML!4 extends the Hello Android XML Hello world from XML!5 class (or Hello Android XML Hello world from XML!6 in the later version), and overrides the Hello Android XML Hello world from XML!1 method. The Hello Android XML Hello world from XML!1 is a call-back method, which is called back by the Android system when the activity is launched. A Hello Android XML Hello world from XML!9 is a UI component (or widget, or control). We construct a ...... ......0 (which is a subclass Hello Android XML Hello world from XML!9 for showing a text message), and set its text. We then set the content-view of the Hello Android XML Hello world from XML!4 screen to this ...... ......0. Android Application Descriptor File - "AndroidManifest.xml"Each Android application has a manifest file named ...... ......4 under "app" ⇒ "manifests". It describes the Android app. For example, our " ...... ......5" application, with an activity called Hello Android XML Hello world from XML!4, has the following manifest (generated automatically by the Android SDK when the project was built):
Hello-World using "XML Layout"Instead of writing Java codes to create the user interface (UI) (as in the above example using a ...... ......0 component). It is more flexible and therefore recommended to layout your UI components via a descriptive XML layout file. In this way, you don't need to hardcode the views, and you can easily modify the look and feel of the application by editing the XML markups. The Java codes can therefore focus on the business logic. Let's rewrite our hello-world to use XML layout. Step 1: Create a New Android AppCLOSE the previous project, via "File" ⇒ "Close Project" (Always CLOSE the previous project before starting a new project). Choose "Start a new Android Studio project" ⇒ "Phone and Tablet" ⇒ "Empty Activity" ⇒ Next ⇒ Set "Name" to " Step 2: Define the Layout in XML File "res\layout\activity_main.xml"Expand the "app", "res (resource)", "layout" node. Open the " Select the "Code" view and study the codes: "Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> The XML declares a ...... ......0 (text field) that holds a text string " java -version 3". The ...... ......0 component has width and height big enough to hold its content (" java -version 5").Step 3: Defining String References and Values in XML File "res\values\string.xml"Instead of hardcoding the Hello-World string directly inside the ...... ......0 (as in the above XML file), we shall use a string reference (or variable) for better flexibility. Expand Hello Android XML Hello world from XML! This "
Now, modify the " ...... ...... Step 4: Program the Activity in "MainActivity.java"Next, check the " The " Hello Android XML Hello world from XML!4" sets its content-view to " JAVA_HOME 9", which is mapped to the XML layout file "set JAVA_HOME 0" that we have modified earlier. |