+ All Categories
Home > Documents > EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Date post: 07-Jul-2015
Category:
Upload: antonis-kalipetis
View: 539 times
Download: 2 times
Share this document with a friend
Description:
First of a workshop series by EESTEC LC Athens for Android. Introduction to Java, OOP and Android
Popular Tags:
28
EESTEC Android Workshops 101 - Introduction to OOP, Java and Android
Transcript
Page 1: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

EESTEC Android Workshops

101 - Introduction to OOP, Java and Android

Page 2: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

What we’ll cover today

EESTEC, Android, it’s APP to you!

Introduction to OOP

Introduction to Java

Setting up the Android Environment

Running your first App

Page 3: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Android, it’s APP to you!

Page 4: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

How do I apply?

Create a great team!

Find an outstanding idea!

Complete a simple form!

Page 5: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Let’s get to the point!OOP, here we come!

Page 6: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Basic ConceptsClass - Blueprint, used to create instances of itself

Object / Instance - Instances are class occurrences

Method - Function / Procedure of an object or class

Attribute - Fields with values (objects) in a object

Page 7: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Pros

Code decoupling, enforces code reusability

Associates data structures with their related methods

Makes real-world object representation easier

Page 8: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Inheritance

Classes can extend other classes

They inherit their attributes and methods

Can extend only one class

Page 9: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Example

HumanWalks, Sleeps

namesurname

sex

AdultWorks

job positioncompanyvat no

KidPlays, Cries

no of toysschool gradeno of friends

Page 10: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Examplepublic class Hello {

public static void main(String[] argv) {

System.out.println(getHelloString()); }

private static String getHelloString() {

return "Hello"; }}

public class HelloWorld extends Hello {

@Override private static String getHelloString() {

return "Hello, world!"; }}

Page 11: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Interfaces

Make a class implement certain functionality

A class can implement more than one interfaces

Page 12: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

ExampleMale

Watch footballSnore

Female

CookBe grumpy for

no reason

Male Kid

Female Adult

Female Human

Page 13: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Examplepublic class Human {

abstract void sayHi(); abstract void sayGoodBye();}

public class Eestecer implements Human {

@Override private static String sayHi() {

System.out.println("Hello guys!"); }

@Override private static String sayGoodBye() {

System.out.println("Goodbye... Keep partying!"); } }

Page 14: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

OOP Languages

C++

Ruby

Python

C#

VB.NET

...And, wait for it...

Page 15: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Java-dive!Let’s take a fast look

Page 16: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Java, at a glanceC-like syntax

Created in Sun Microsystems, by James Gosling

Now acquired by Oracle

Page 17: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Hello, Java World!

public class HelloJava { public static void main(String[] argv) {

System.out.println(“Hello, Java World!”);}

Page 18: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Great Things about Java

Has a garbage collector, simply do not care about memory leakage!

Your program fails, except exceptions!

Is platform-independent, runs in it’s own VM, the JVM

Page 19: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Garbage Collector

Java objects leave in a heap

When the Garbage Collector needs to release memory, it starts removing dangling objects

Slightly pauses the application threads

Page 20: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Exceptions

Java gives you the chance to get a bit off track, but then makes sure you can handle unwanted situations

You can try something weird and if it turns bad, you handle the exception

Page 21: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Example

try {

something that might destroy the universe

catch (EarlyDestructionExcpetion e) { save the world}

Page 22: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Say hello, to my Green friend

Page 23: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

The mystery, explained...Complete software stack

Operating System

Middleware

Key Applications

Open Source Developed by the Open Handset Alliance

Fastest growing market

Platform with the most devices activations

Page 24: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Android, bottoms up!

Page 25: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Setup a new project

Page 26: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Activity

Creates a window, so that the user can interact with the app

Can communicate with the system

Controls the higher level of the user interface

Page 27: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android

Activity, get a life!

The lifecycle of an Activity is really important.

Listen to Lifecycle events, in order to save and reproduce

the state of the app


Recommended