![Page 1: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/1.jpg)
Mobile ProgrammingLecture 1
Getting Started
![Page 2: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/2.jpg)
Today's Agenda
● About the Android Studio IDE● Hello, World! Project● Android Project Structure● Introduction to Activities, Layouts, and Widgets● Editing Files in Android Studio● SDK Tools
![Page 3: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/3.jpg)
About the Android Studio IDE
● Android Studio is an IDE as Visual Studio is an IDE○ Android Studio is now the official IDE for developing
Android applications and is based on IntelliJ IDEA by JetBrains
● It is a great tool, but there is a chance you will run into problems.○ Lots of online resources including the reference
page from the Android Developer site
![Page 4: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/4.jpg)
Getting the Android Studio IDE
● You can download the latest version of Android Studio for your OS from the following URL○ http://developer.android.com/sdk/index.html
● The installation will also guide you through downloading and/or installing other components○ SDK○ Emulator Images○ etc.
![Page 5: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/5.jpg)
Hello, World! Project - Navigation
From the Android Studio main menu● File > New > New Project● In the Create New Project Window
○ Application Name: The name of your Android application○ Company Domain: Your company’s (or personal domain).
■ e.g. mobile.cs.fsu.edu - reverse is used in combination with application name to create a package name (edu.fsu.cs.mobile.helloworld)
■ The package name can be set manually by clicking the edit link and entering the new package name
○ Project Location: Local path where the application should be created
● Next
![Page 6: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/6.jpg)
Hello, World! Project - Form Factors
● Select the different form factors that your app is intended to run on○ Phone and Tablet
■ This is the form-factor that will be used for most of the course○ Wear
■ If there is adequate time, we will explore developing wearable apps towards the end of the course
○ TV○ Android Auto○ Glass
● Specify the minimum Android SDK that will be supported by your app○ You will be expected to develop apps that target a minimum
SDK of Android 4.0 (ICS) or API 14
![Page 7: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/7.jpg)
Hello, World! Project - Add an Activity
● Presents several default Activity templates● Select Empty Activity● Click Next● Provide a name for the Activity● Ensure the Generate Layout File option is
checked○ This ensures that a layout is generated for your
default Activity when the project is created● Provide a name for the layout file● Click Finish
![Page 8: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/8.jpg)
Hello, World! Project - Setup an Emulator
● In Android Studio, select Tools > Android > AVD Manager
● In the Android Virtual Device Manager, select Create Virtual Device
● Select a Hardware Device and click Next● Choose a System Image and click Next
○ Ensure your device runs at least Ice Cream Sandwich● Provide a name for the AVD
○ You can accept or change the defaults as necessary or modify the advanced settings to suit your needs
● Click Finish
![Page 9: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/9.jpg)
Hello, World! Project - execution
● To run your project○ Shift + F10 or○ Select Run from the Run menu
● If necessary○ Click Yes to launch a new virtual device○ Choose to run as Android Application
![Page 10: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/10.jpg)
Project Structure
● build/ stores the compiled app● src/main/res/ contains drawable files, layouts,
string values, etc.● src/main/java/ contains your source code● AndroidManifest.xml file describes the
application● R.java - do not modify this!
○ generated whenever the project compiles○ more on this later
![Page 11: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/11.jpg)
Activities - Examples
● 3 different apps, 3 different activities
![Page 12: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/12.jpg)
Activities - Examples
● 1 app (Google Maps), 3 different Activities
![Page 13: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/13.jpg)
Activities - Examples
● 1 app (Clock), 3 different Activities
![Page 14: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/14.jpg)
Activities
● An Activity is a UI-based construct focusing on a single user task
● To create an Activity, you must create a class that extends Activity (or one of its subclasses)
● Main point of entry○ int main() is the main point of entry in C++○ public static void main(string args[]) is for Java○ public void onCreate(Bundle savedInstance) for Android!
![Page 15: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/15.jpg)
Layouts
Defines the layout structure and holds all elements in an Activity
![Page 16: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/16.jpg)
Layouts
● LinearLayout● RelativeLayout● TableLayout● TabLayout
![Page 17: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/17.jpg)
Layouts - LinearLayout
Organizes UI components in a straight line as either a row or column
![Page 18: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/18.jpg)
Layouts - LinearLayout
1
![Page 19: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/19.jpg)
Layouts - LinearLayout
1button, textbox, checkbox, etc.
![Page 20: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/20.jpg)
Layouts - LinearLayout
12
![Page 21: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/21.jpg)
Layouts - LinearLayout
123
![Page 22: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/22.jpg)
Layouts - LinearLayout
123
n
.
.
.
![Page 23: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/23.jpg)
Widgets
Widgets are UI elements that appear in an Activity (inside of Layouts!)● Buttons● TextViews (labels)● CheckBoxes● Many more!
![Page 24: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/24.jpg)
Editing Files in Android Studio
● XML Files○ Plain XML editor
■ edit XML files directly○ Form based editor
■ allows you to modify XML files indirectly using forms● Content Assist
○ Similar to Intellisense, autocomplete○ When in doubt, press Ctrl + Spacebar
● Quick fixes○ e.g. import a package without typing anything
● WYSIWYG editor○ Allows you to drag and drop Widgets into your Layouts○ "What You See Is What You Get"
![Page 25: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/25.jpg)
SDK Tools
● Development and debugging tools for Android
● SDK Manager○ Allows you to install tools necessary to develop for
specific Android platforms● In Android Studio
○ Tools > Android > SDK Manager
![Page 26: Mobile Programming Lecture 1 - Florida State Universityww2.cs.fsu.edu/~yannes/lectures/lect01.Getting.Started.pdf · Mobile Programming Lecture 1 Getting Started. Today's Agenda About](https://reader034.vdocuments.mx/reader034/viewer/2022042812/5fadcc29c30c205d66359302/html5/thumbnails/26.jpg)
References
● Android Developers● The Mobile Lab at Florida State University