App Development

Day 1: Introduction to Java

and Android Studio

Administrative Comments

  • Introductions
  • Rules
  • Course description
  • Survey
  • Icebreaker

Course Description

  • What you will do in this course:
    • Be introduced the basics of Android app development
    • Be introduced to the Android Studio IDE
    • Learn Java through Android app development

Rules

  • Everyone gets respect
  • No food; water only 
  • Leave no one behind
    • "Three before me": ask at least three peers before asking an instructor
  • No phones/tablets/other miscellaneous devices except with instructor approval 
    • In Android Studio, we will be using smartphone emulators, which are emulators of almost every Android smartphone you can think of, so you won't need your phones
  • No gaming/VPNs/extraneous activities
    • Tip: be very careful what you do on Punahou WiFi

Why Android Studio?

  • Official Android IDE
  • Other obvious reasons

Programming Survey

  • Because there are a lot of you and probably a wide skill range, we would like to better tailor the course to you guys
  • We need to gauge overall programming knowledge to better instruct you all
  • Please follow the instructions in the next slide closely
    • ​We will not answer questions that have been answered on the slide

Programming Survey

  • Open Chrome
  • Go to this URL:
  • https://www.surveymonkey.com/r/YW3FL77
  • Take the survey and press "Done" when done
    • Do NOT attempt to look up the answers
    • If you did not know much, that is fine; we just want to know what to teach

 

Icebreaker Activity

  • We will put you into random groups
  • It is okay if you didn't know any of the answers
    • But please try to understand them and ask your group members for help
  • Introduce yourself to your group members
  • Come up with answers to the quiz questions
    • You MAY use Google
  • We will then slowly merge the groups until the entire class has a solution set to present

General Review

  • Go over answers
  • Play GeoQuiz Game on Android Studio phone emulator

Getting Started with Android Studio

  • Import GeoQuiz app from GitHub
    • https://github.com/junior-devleague/AndroidAppDevelopment
    • Click on "GeoQuiz.7z"
    • Download and extract
  • Open Android Studio
    • File > Open > Select GeoQuiz directory

What is Programming?

  • Basically telling the computer what to do
  • People write out code, which is translated into machine language and executed
  • Code is read sequentially, top-down
    • The computer processes every line of code that you write and executes it exactly as written

Object Oriented Programming

  • Reusable programming objects
  • Like manufacturing multiple cars; instead of redesigning each part every time, a blueprint is made and the cars are created using that blueprint
    • When the class is made into a real working thing, it's called an object
    • Blueprint == class

How Java Works

  • Code is written in a programming language (in this case, Java)
  • That human-readable code is compiled into machine language so the computer can execute it using its OS or processor
    • Java is special, it compiles into bytecode, which is run by the JVM
  • Java Virtual Machine (JVM)
    • Abstract computing machine that mimics a processor so it can execute Java bytecode
    • Enables a computer to run a Java program

Java (and Programming) Basics

  • Syntax
  • Data Types
  • Operators
  • Variables
  • Conditional Statements
  • Loops

Syntax

  • Basically grammar for computers
  • Someone give an example of a grammatically correct ENGLISH sentence!
  • Now move around the punctuation and randomize the capitalization and scramble the words
  • There's a grammar for every language, including computer language -- it's called syntax!

Basic Data Types

  • String
  • boolean
  • int
  • short
  • long
  • float
  • double
  • char

Hello World!

  • Open up your Terminal
    • cd Documents
    • mkdir java_work
    • nano hello_world.java
class hello_world {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
  • Back to the terminal
    • javac hello_world.java
    • java hello_world

Operators

  • +, -, *, /, %, <, >
  • Order of operations anyone?
  • nano hello_world.java
class hello_world {
    public static void main(String[] args) {
        int number = 5*5+10;
        System.out.println(number);
    }
}
  • Back to the terminal
    • javac hello_world.java
    • java hello_world

= vs ==

  • = is assignment
    • ex int num = 10;
  • == is comparing values and checking for equality
    • Returns true or false
    • ex num == 10;

Variables

  • A variable is something that store data
  • Must follow certain naming conventions
    • NEVER start with a number
    • NO spaces
      • Use underscores or camel casing
      • ex thisIsCamelCasing
    • No special characters (*,.!@#;: etc)
  • In Java, they must be typecasted
    • ex int varName = 10;
    • ex String varName = "This is a string.";
  • Syntax: dataType variableName = value;
    • When initializing, if you don't assign a value, it gets set to null, 0, or false.

App Development

By ifang

App Development

  • 476