2013.11.09
#DevFest Lombardia
#DevFestLomb
@ Università degli Studi Milano Bicocca
Who I Am
+MatteoGazzurelli

CEO / Android Developer
DUCKMA srl - Brescia
@gazzumatteo
2
#devfestlomb

Introduction to Android
Android, the unknown...
3
Android, questo sconosciuto...

• 

Mobile Operating System by Android Inc.

• 

Bought by Google in 2005

• 

Unveiled in...
Why develop for Android?

• 

Is adaptable and functional

• 

Very good OS

• 

Good Business!

5
Google’s Role

• 

Development & Support

• 

Google Play

• 

Nexus

Developers

6
Android 101
In theory…. and in practice.

7
Java Based
Java VM

Java

Hello World

Dalvik VM

8
What do I need to know to be a programmer?

• 

OOP (Object Oriented Programming)

• 

Encapsulation, Inheritance,
Polymor...
Inside the Droid
Architecture & Theory

10
Android Architecture
Application
Home, Contacts, Telephone, Browser, …

Application Framework
Managers for Activity, Windo...
Four pillars of Android

• 

Activities

• 

Services

• 

Broadcast Receivers

• 

Content Providers

12
Activities

• 

Activity is the main component of Android, represent
a single screen whit a user interface

• 

Is like a ...
Activity Lifecycle

14
Introduction to Intents

• 
• 
• 

Intents are used as a message-passing mechanism
that works both within your application...
Services

• 
• 
• 
• 

Application components that can perform longrunning operations in the background
Doesn’t provide a ...
Service Lifecycle

17
Broadcast Receiver

• 

A Broadcast receiver is a component that does nothing
but receive and react to broadcast announcem...
Content Provider

• 
• 
• 
• 
• 
• 

Content Providers manage access to a structured set of
data
Are the standard interfac...
Content Provider

20
Hands On
Down and dirty!

21
Craftsman tools

• 

IDE

• 

Tools:

• 
• 
• 
• 
• 
• 

Eclipse
Android Studio

ADT (Android Developer Tools)
Android SDK...
Eclipse / Android Studio

23
Android SDK Manager (via ADT)

24
Android Virtual Device Manager (AVD)

25
LogCat

26
Debug

27
Let’s start a new project
Gentlemen start your engines!

28
File -> New Project

29
Tutorial

30
Project structure

31
Src

• 

Java Classes

• 

Organized in Packages

• 
• 
• 
• 

Activity
Fragment
Adapter
Models

32
Activity
Sample Code
package com.example;

JAVA

import android.app.Activity;
import android.os.Bundle;
public class MainA...
Fragments

• 

Since Android 3.0

• 

Represent a portion of the UI in an activity

• 

Can combine multiple fragment in a...
Assets e Lib

• 

Assets

• 

Libs

• 
• 
• 

Not optimized and compiled resources

External libraries
Java o C

35
Resources

• 
• 
• 

Any other information that are not code
Stored in config files external to code (but inside the final
ap...
Classe R.java

• 

Bridge between activities and resources

• 

In gen/

• 

Dynamically generated (by Android’s Eclipse p...
Resource Example
String.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

XML

<string name="app_name">Test</string...
Layout

• 

XML Files

• 

Defines the visual structure for a user interface

• 

Target many resolutions

39
Layout Example
Activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="h...
Widget

• 

Visual Components of Android

• 
• 
• 
• 
• 
• 

Button
TextView
EditText
WebView
ImageView
…

41
Widget Example
Button
JAVA

Button myButton = new Button(this);
myButton.setText(R.string.button_back);
myButton.setLayout...
Eclipse UI Builder

43
Views

• 

Base component for UI (Widget)

• 

Layout

• 

View Groups

• 
• 

Visual structure of the UI

Invisible Conta...
Manifest

• 

Contains the essential information about the application

• 

Other elements to declare

• 
• 
• 
• 
• 

Ver...
Design Pattern

• 

Model – View – Controller

• 

Model – View – Presenter

• 

In the official Android documentations does...
Fragmentation
‘minSdkVersion=“14”’

47
Android Family Tree

1.5 Cupcake

1.6 Donut

2.0 Eclair

2.2 Froyo

2.3 Gingerbread

4.4 KitKat

3.0 Honeycomb
4.0 Ice Cre...
November Fragmentation Status

49
How many Display!

Screen Types

vs

Screen Sizes
50
Suggestions (No Panic!)

• 

Choose the right target of your application

• 
• 
• 
• 

Learn how to use correctly the res....
Publish
Make public your creations!

52
Markets

• 

Google

• 

Samsung

• 

Amazon

• 

Any other market (your)

53
Google Play Store

54
Google Play Store - Publish

55
Google Play Store - Stats

56
Introduction to Android – The End
+MatteoGazzurelli
That’s me!

#devfestlomb
matteo@duckma.com

Thank You & Have Fun!
57
Questions?

58
Links

• 
• 
• 
• 

Android Developer
http://developer.android.com
Android Design Guidelines
http://developer.android.com/...
Introduction to Android – The End
+MatteoGazzurelli
That’s me!

#devfestlomb
matteo@duckma.com

Thank You & Have Fun!
60
Upcoming SlideShare
Loading in...5
×

Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013

285

Published on

Introduction to Android - Google #DevFestLomb 2013 @ Università degli Studi di Milano Bicocca #DevFest

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
285
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013"

  1. 1. 2013.11.09 #DevFest Lombardia #DevFestLomb @ Università degli Studi Milano Bicocca
  2. 2. Who I Am +MatteoGazzurelli CEO / Android Developer DUCKMA srl - Brescia @gazzumatteo 2
  3. 3. #devfestlomb Introduction to Android Android, the unknown... 3
  4. 4. Android, questo sconosciuto... •  Mobile Operating System by Android Inc. •  Bought by Google in 2005 •  Unveiled in 2007 3
  5. 5. Why develop for Android? •  Is adaptable and functional •  Very good OS •  Good Business! 5
  6. 6. Google’s Role •  Development & Support •  Google Play •  Nexus Developers 6
  7. 7. Android 101 In theory…. and in practice. 7
  8. 8. Java Based Java VM Java Hello World Dalvik VM 8
  9. 9. What do I need to know to be a programmer? •  OOP (Object Oriented Programming) •  Encapsulation, Inheritance, Polymorphism •  Interfaces •  Listeners •  Packages structure 9
  10. 10. Inside the Droid Architecture & Theory 10
  11. 11. Android Architecture Application Home, Contacts, Telephone, Browser, … Application Framework Managers for Activity, Window, Package, … Libraries SQLite, OpenGL, SSL, … Runtime Dalvik VM, Core libs Kernel Linux Driver for Display, Camera, Flash, Wifi, Audio, … 11
  12. 12. Four pillars of Android •  Activities •  Services •  Broadcast Receivers •  Content Providers 12
  13. 13. Activities •  Activity is the main component of Android, represent a single screen whit a user interface •  Is like a form in traditional languages such as Visual Basic or like a single HTML page 13
  14. 14. Activity Lifecycle 14
  15. 15. Introduction to Intents •  •  •  Intents are used as a message-passing mechanism that works both within your application, and between applications. Interacts with every components in Android Used for: •  •  •  Declare your intention that an Activity or Service be started to perform an action, usually with a piece of data ( startActivity(Intent); ) Broadcast that an event (or action) has occurred Explicity start a particular Service or Activity 15
  16. 16. Services •  •  •  •  Application components that can perform longrunning operations in the background Doesn’t provide a user interface Service is not a separate process or thread Service is a simple class, you must implement separate threads by yourself 16
  17. 17. Service Lifecycle 17
  18. 18. Broadcast Receiver •  A Broadcast receiver is a component that does nothing but receive and react to broadcast announcements •  Broadcast Intent •  Your app can: •  •  •  Receive and react to system services (ex. Battery low) Receive and react to other apps broadcast announcements Initiate broadcasts to other apps 18
  19. 19. Content Provider •  •  •  •  •  •  Content Providers manage access to a structured set of data Are the standard interface that connects data in one process with code running in another process Any application with appropriate permission, can read and write the data Files, SQL Database Expose a public URI that uniquely identifies its data set “content://…” 19
  20. 20. Content Provider 20
  21. 21. Hands On Down and dirty! 21
  22. 22. Craftsman tools •  IDE •  Tools: •  •  •  •  •  •  Eclipse Android Studio ADT (Android Developer Tools) Android SDK Tools Android Platform Tools AVD (Android Virtual Device) / Emulator 22
  23. 23. Eclipse / Android Studio 23
  24. 24. Android SDK Manager (via ADT) 24
  25. 25. Android Virtual Device Manager (AVD) 25
  26. 26. LogCat 26
  27. 27. Debug 27
  28. 28. Let’s start a new project Gentlemen start your engines! 28
  29. 29. File -> New Project 29
  30. 30. Tutorial 30
  31. 31. Project structure 31
  32. 32. Src •  Java Classes •  Organized in Packages •  •  •  •  Activity Fragment Adapter Models 32
  33. 33. Activity Sample Code package com.example; JAVA import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override protected void onPause(Bundle savedInstanceState) { super.onPause(); } } 33
  34. 34. Fragments •  Since Android 3.0 •  Represent a portion of the UI in an activity •  Can combine multiple fragment in a single activity •  Have their lifecycle •  Live in a ViewGroup 34
  35. 35. Assets e Lib •  Assets •  Libs •  •  •  Not optimized and compiled resources External libraries Java o C 35
  36. 36. Resources •  •  •  Any other information that are not code Stored in config files external to code (but inside the final apk package) Contain •  •  •  •  Drawable Layouts Xml Values 36
  37. 37. Classe R.java •  Bridge between activities and resources •  In gen/ •  Dynamically generated (by Android’s Eclipse plugin) and contains numeric constant referred to every resources of the project •  Contains only public fields (“public static final”) 37
  38. 38. Resource Example String.xml <?xml version="1.0" encoding="utf-8"?> <resources> XML <string name="app_name">Test</string> <string name="action_settings" >Settings</string> <string name="hello_world" >Hello world!</string> </resources> 38
  39. 39. Layout •  XML Files •  Defines the visual structure for a user interface •  Target many resolutions 39
  40. 40. Layout Example Activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > XML <TextView android:layout_width="wrap_content” android:layout_height="wrap_content" android:text="@string/hello_world" /> </RelativeLayout> 40
  41. 41. Widget •  Visual Components of Android •  •  •  •  •  •  Button TextView EditText WebView ImageView … 41
  42. 42. Widget Example Button JAVA Button myButton = new Button(this); myButton.setText(R.string.button_back); myButton.setLayoutParams(new LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT )); XML <Button android:id="@+id/button1” android:layout_width="wrap_content” android:layout_height="wrap_content” android:layout_alignLeft="@+id/textView1” android:layout_below="@+id/textView1” android:layout_marginLeft="41dp” android:text="Button” /> 42
  43. 43. Eclipse UI Builder 43
  44. 44. Views •  Base component for UI (Widget) •  Layout •  View Groups •  •  Visual structure of the UI Invisible Container that contains other View or ViewGroup 44
  45. 45. Manifest •  Contains the essential information about the application •  Other elements to declare •  •  •  •  •  Version Name Icon Permission Features •  •  •  •  •  •  Activity Services Provider Receiver uses-sdk uses-permission 45
  46. 46. Design Pattern •  Model – View – Controller •  Model – View – Presenter •  In the official Android documentations doesn’t exists any referral to these patterns •  •  Activity -> Controller Activity -> View 46
  47. 47. Fragmentation ‘minSdkVersion=“14”’ 47
  48. 48. Android Family Tree 1.5 Cupcake 1.6 Donut 2.0 Eclair 2.2 Froyo 2.3 Gingerbread 4.4 KitKat 3.0 Honeycomb 4.0 Ice Cream Sandwich 4.1 Jelly Bean 48
  49. 49. November Fragmentation Status 49
  50. 50. How many Display! Screen Types vs Screen Sizes 50
  51. 51. Suggestions (No Panic!) •  Choose the right target of your application •  •  •  •  Learn how to use correctly the res. Support library Test on at least two devices Fragmentation can be an advantage •  minSdkVersion=“14” 51
  52. 52. Publish Make public your creations! 52
  53. 53. Markets •  Google •  Samsung •  Amazon •  Any other market (your) 53
  54. 54. Google Play Store 54
  55. 55. Google Play Store - Publish 55
  56. 56. Google Play Store - Stats 56
  57. 57. Introduction to Android – The End +MatteoGazzurelli That’s me! #devfestlomb matteo@duckma.com Thank You & Have Fun! 57
  58. 58. Questions? 58
  59. 59. Links •  •  •  •  Android Developer http://developer.android.com Android Design Guidelines http://developer.android.com/design/ Play Store Publish http://play.google.com/apps/publish/ Duckma http://duckma.com 59
  60. 60. Introduction to Android – The End +MatteoGazzurelli That’s me! #devfestlomb matteo@duckma.com Thank You & Have Fun! 60

×