EESTEC Summer School 2012 - Branding Guidelines - Milosh Pivic
EESTEC Android Workshops - 101 Java, OOP and Introduction to Android
-
Upload
antonis-kalipetis -
Category
Documents
-
view
536 -
download
2
description
Transcript of EESTEC Android Workshops - 101 Java, OOP and Introduction to Android
![Page 1: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/1.jpg)
EESTEC Android Workshops
101 - Introduction to OOP, Java and Android
![Page 2: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/2.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/3.jpg)
Android, it’s APP to you!
![Page 4: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/4.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/5.jpg)
Let’s get to the point!OOP, here we come!
![Page 6: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/6.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/7.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/8.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/9.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/10.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/11.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/12.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/13.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/14.jpg)
OOP Languages
C++
Ruby
Python
C#
VB.NET
...And, wait for it...
![Page 15: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/15.jpg)
Java-dive!Let’s take a fast look
![Page 16: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/16.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/17.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/18.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/19.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/20.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/21.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/22.jpg)
Say hello, to my Green friend
![Page 23: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/23.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/24.jpg)
Android, bottoms up!
![Page 25: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/25.jpg)
Setup a new project
![Page 26: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/26.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/27.jpg)
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
![Page 28: EESTEC Android Workshops - 101 Java, OOP and Introduction to Android](https://reader033.fdocuments.us/reader033/viewer/2022060202/559b762b1a28ab744f8b4787/html5/thumbnails/28.jpg)
Tasks for next time
1. Create an application that asks for the user’s name
2.Then, after hitting a button, it populates a text view with a personalized message for the user
3.When the button is pressed, a clear button appears that resets everything
Hint: Check the following classes: TextView, EditText, Button and OnClickListener