SlideShare uma empresa Scribd logo
1 de 36
Baixar para ler offline
Android Programming
Daniela da Cruz
Instituto Politécnico do Cávado e do Ave
III Jornadas de Tecnologia
May 6, 2013
1 of 14
The Story
Advantages of using Android
Disadvantages of using Android
What will be done along this workshop?
How to start programming?
2 of 14
The Story
- Android is a is a Linux-based operating system for smartphones and
tablets created by Google.
- Developers write applications in a customized version of Java, and
apps can be downloaded from online stores such as Google Play
(formerly Android Market), the app store run by Google, or third-party
sites.
- In June 2012, there were more than 600 000 apps available for
Android, and the estimated number of applications downloaded from
Google Play was 20 billion (according to
http://www.engadget.com).
3 of 14
The Story
4 of 14
The Story
5 of 14
The Story
6 of 14
The Story
7 of 14
The Story
8 of 14
The Story
9 of 14
Advantages of using Android
• The Android OS is simple to learn, and Google provides many
libraries to make it easy to implement rich and complex applications
• Multitasking: Android phones can run many applications, it means
you can browse Facebook while listening a song.
• Easy access to thousands of applications via the Google Android
App Market.
• Phone options are diverse: dierent from iOS that is limited to
iPhone from Apple, Android is available on mobile phones from
various manufacturers (Sony Ericsson, Motorola, HTC to
Samsung).
10 of 14
Disadvantages of using Android
• The only aspect lacking, as mentioned by many in the Android
developer community, is clear and well-explained documentation.
• Advertising: application in the Android phones can indeed be
obtained easily and for free, but the consequences in each of these
applications, will always be ads on display, either the top or bottom
of the application.
11 of 14
What will be done in this workshop?
• The classical Hello World!
• Take a pic and show it in our app
• Show a Google Map and change its center using our location
12 of 14
How to start programming?
• Download and install the Android SDK (4.2 version - Jelly Bean)
 it provides the API libraries and developer tools necessary to
build, test, and debug apps for Android.
Details on http://developer.android.com/sdk/index.html
Pre-requisites:
• Eclipse 3.6.2 (Helios) or greater
• Eclipse JDT plugin (included in most Eclipse IDE packages)
• JDK 6 (JRE alone is not sucient)
• Android Development Tools plugin (recommended)
13 of 14
Android Application Overview
Activity Lifecycle
Basic Android User Interface components
Activity
Fragments
View and ViewGroup
Layouts
AbsoluteLayout
FrameLayout
LinearLayout
RelativeLayout
TableLayout
XML Layout Attributes
Dimensions
2 of 20
Android Application Overview
An Android application consists of various functionalities. Some
examples are editing a note, playing a music file, ringing an alarm, or
opening a phone contact.These functionalities can be classified into
four different Android components:
Every application is made up of one or more of these components.
3 of 20
Activity Lifecycle
4 of 20
Activity Lifecycle
Note the following:
• Changing the screen orientation destroys and recreates the activity
from scratch.
• Pressing the Home button pauses the activity, but does not destroy
it.
• Pressing the Application icon might start a new instance of the
activity, even if the old one was not destroyed.
• Letting the screen sleep pauses the activity and the screen
awakening resumes it. (This is similar to taking an incoming phone
call.)
5 of 20
Activity
An Activity represents the visual representation of an Android
application.
Activities use Views and Fragments to create the user interface and
to interact with the user.
An Android application can have several Activities.
6 of 20
Fragments
Fragments are components which run in the context of an Activity.
Fragment components encapsulate application code so that it is easier
to reuse it and to support different sized devices.
Fragments are optional, you can use Views and ViewGroups directly in
an Activity but in professional applications you always use them to
allow the reuse of your user interface components on different sized
devices.
7 of 20
View and ViewGroup
Views are user interface widgets, e.g. buttons or text fields. The base
class for all Views is the android.view.View class. Views have attributes
which can be used to configure their appearance and behavior.
A ViewGroup is responsible for arranging other Views. ViewGroups is
also called layout managers. The base class for these layout managers
is the android.view.ViewGroup class which extends the View class.
ViewGroups can be nestled to create complex layouts. You should not
nestle ViewGroups too deeply as this has a negative impact on the
performance.
8 of 20
View and ViewGroup
The user interface for each component of your app is defined using a
hierarchy of View and ViewGroup objects.
The easiest and most effective way to define a layout is with an XML
file.
9 of 20
Layouts
An Android layout is a class that handles arranging the way its
children appear on the screen. Anything that is a View (or inherits
from View) can be a child of a layout. All of the layouts inherit from
ViewGroup (which inherits from View) so you can nest layouts.
The standard Layouts are:
• AbsoluteLayout
• FrameLayout
• LinearLayout
• RelativeLayout
• TableLayout
10 of 20
XML Layout Attributes
At compile time, references to the resources are gathered into an
auto-generated wrapper class called R.java. The Android Asset
Packaging Tool (aapt) autogenerates this file.
The syntax for an ID, inside an XML tag is:
android:id=@+id/my_button
The at-symbol (@) at the beginning of the string indicates that the
XML parser should parse and expand the rest of the ID string and
identify it as an ID resource. The plus-symbol (+) means that this is a
new resource name that must be created and added to the R.java file.
16 of 20
XML Layout Attributes
When referencing an Android resource ID, you do not need the
plus-symbol, but must add the android package namespace, like so:
android:id=@android:id/empty
With the android package namespace in place, we’re now referencing
an ID from the android.R resources class, rather than the local
resources class.
17 of 20
XML Layout Attributes
In order to create views and reference them from the application, a
common pattern is to:
1. Define a view/widget in the layout file and assign it a
unique ID:
Button android:id=@+id/my_button
android:layout_width=wrap_content
android:layout_height=wrap_content
android:text=@string/my_button_text/
18 of 20
XML Layout Attributes
In order to create views and reference them from the application, a
common pattern is to:
2. Then create an instance of the view object and capture
it from the layout (typically in the onCreate() method):
Button myButton = (Button) findViewById(R.id.my_bu
Defining IDs for view objects is important when creating a
RelativeLayout. In a relative layout, sibling views can define their
layout relative to another sibling view, which is referenced by the
unique ID.
19 of 20
Dimensions
A dimension is specified with a number followed by a unit of measure.
The following units of measure are supported by Android:
• dp — Density-independent Pixels: An abstract unit that is based on
the physical density of the screen. These units are relative to a 160
dpi (dots per inch) screen, on which 1dp is roughly equal to 1px.
When running on a higher density screen, the number of pixels used
to draw 1dp is scaled up by a factor appropriate for the screen’s dpi.
• sp — Scale-independent Pixels: This is like the dp unit, but it is
also scaled by the user’s font size preference.
• pt — Points: 1/72 of an inch based on the physical size of the
screen.
20 of 20
Dimensions
A dimension is specified with a number followed by a unit of measure.
The following units of measure are supported by Android:
• px — Pixels: Corresponds to actual pixels on the screen. This unit
of measure is not recommended because the actual representation
can vary across devices.
• mm — Millimeters: Based on the physical size of the screen.
• in — Inches: Based on the physical size of the screen.
21 of 20
Intents
Explicit Intents
Implicit Intents
Using Intents to call Activities
Calling Sub-Activities for result data
2 of 8
Intents
Intents are asynchronous messages which allow Android components
to request functionality from other components of the Android system.
For example an Activity can send an Intents to the Android system
which starts another Activity.
An Intent can also contain data. This data can be used by the
receiving component.
There are two types of Intents: Explit and Implict.
3 of 8
Explicit Intents
Explicit Intents explicitly defines the component which should be
called by the Android system, by using the Java class as identifier.
The following shows an explicit Intent.
Explicit Intents are typically used within on application as the classes
in an application are controlled by the application developer.
4 of 8
Implicit Intents
Implicit Intents do not directly specify the Android components which
should be called.
For example the following tells the Android system to view a webpage.
If these Intents are send to the Android system it searches for all
components which are registered for the specific action and the data
type.
If only one component is found, Android starts this component
directly. If several components are identifier by the Android system,
the user will get an selection dialog and can decide which component
should be used for the Intent.
5 of 8
Retrieving data from Intents
The component which receives the Intent can use the
getIntent().getExtras() method call to get the extra data.
6 of 8
Using Intents to call Activities
If you send an Intent to the Android system, Android requires that you
tell it to which type of component your Intent should be send.
To start an Activity use the method startActivity(Intent). This
method is defined on the Context object and available in every
Activity object.
If you call an Activity with the startActivity(Intent) method the
caller requires no result from the called Activity.
7 of 8
Calling Sub-Activities for result data
If you need some information from the called Activity use the
startActivityForResult() method.
If you use the startActivityForResult() method then the started
Activity is called a Sub-Activity.
8 of 8
Bibliography
• Android - Introdução ao Desenvolvimento de Aplicações, Ricardo
Queirós (Abril 2013).
• Programming Android. Zigurd Mednieks, Laird Dornin, G. Blake
Meike, Masumi Nakamura. O'Reilly Media. July 2011
• The Android Developer's Cookbook: Building Applications with the
Android SDK. James Steele, Nelson To.
• http://www.learn-android.com
• http://www.vogela.com
14 of 14

Mais conteúdo relacionado

Mais procurados

Intents in Android
Intents in AndroidIntents in Android
Intents in Androidma-polimi
 
Android App Development 07 : Intent & Share
Android App Development 07 : Intent & ShareAndroid App Development 07 : Intent & Share
Android App Development 07 : Intent & ShareAnuchit Chalothorn
 
Android - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionAndroid - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionMazenetsolution
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversCodeAndroid
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intentDiego Grancini
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recieversUtkarsh Mankad
 
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsAndroid Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsDenis Minja
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)Oum Saokosal
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in androidOum Saokosal
 
Svm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweetsSvm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweetsS M Raju
 
Broadcast Receivers in Android
Broadcast Receivers in AndroidBroadcast Receivers in Android
Broadcast Receivers in Androidma-polimi
 
Ejercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSEEjercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSERicardoGuti50
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)rishi ram khanal
 

Mais procurados (19)

Android development session 2 - intent and activity
Android development   session 2 - intent and activityAndroid development   session 2 - intent and activity
Android development session 2 - intent and activity
 
Intents in Android
Intents in AndroidIntents in Android
Intents in Android
 
Android intents in android application-chapter7
Android intents in android application-chapter7Android intents in android application-chapter7
Android intents in android application-chapter7
 
Android App Development 07 : Intent & Share
Android App Development 07 : Intent & ShareAndroid App Development 07 : Intent & Share
Android App Development 07 : Intent & Share
 
Android - Intents - Mazenet Solution
Android - Intents - Mazenet SolutionAndroid - Intents - Mazenet Solution
Android - Intents - Mazenet Solution
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast Receivers
 
Android App Development - 02 Activity and intent
Android App Development - 02 Activity and intentAndroid App Development - 02 Activity and intent
Android App Development - 02 Activity and intent
 
Android intents, notification and broadcast recievers
Android intents, notification and broadcast recieversAndroid intents, notification and broadcast recievers
Android intents, notification and broadcast recievers
 
Android Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intentsAndroid Bootcamp Tanzania:intents
Android Bootcamp Tanzania:intents
 
Android Lesson 2
Android Lesson 2Android Lesson 2
Android Lesson 2
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)
 
Using intents in android
Using intents in androidUsing intents in android
Using intents in android
 
Svm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweetsSvm and maximum entropy model for sentiment analysis of tweets
Svm and maximum entropy model for sentiment analysis of tweets
 
Broadcast Receivers in Android
Broadcast Receivers in AndroidBroadcast Receivers in Android
Broadcast Receivers in Android
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
Ejercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSEEjercicio de Visual Basic IF THEN ELSE
Ejercicio de Visual Basic IF THEN ELSE
 
GUI (graphical user interface)
GUI (graphical user interface)GUI (graphical user interface)
GUI (graphical user interface)
 
Event handling
Event handlingEvent handling
Event handling
 
Event handling in Java(part 1)
Event handling in Java(part 1)Event handling in Java(part 1)
Event handling in Java(part 1)
 

Destaque

02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - AndroidWingston
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - AndroidWingston
 
02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)TECOS
 
Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Ted Liang
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android StudioMichael Pan
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android StudioSuyash Srijan
 
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaAndroid | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaJAX London
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating systemSalma Begum
 

Destaque (13)

02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - Android
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
The android activity lifecycle
The android activity lifecycleThe android activity lifecycle
The android activity lifecycle
 
02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)
 
Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)Android Activity Transition(ShareElement)
Android Activity Transition(ShareElement)
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android Studio
 
Android studio 2.0
Android studio 2.0Android studio 2.0
Android studio 2.0
 
Android studio
Android studioAndroid studio
Android studio
 
Introduction to Android and Android Studio
Introduction to Android and Android StudioIntroduction to Android and Android Studio
Introduction to Android and Android Studio
 
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaAndroid | Android Activity Launch Modes and Tasks | Gonçalo Silva
Android | Android Activity Launch Modes and Tasks | Gonçalo Silva
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating system
 
Android ppt
Android ppt Android ppt
Android ppt
 

Semelhante a Android Introduction

Android apps development
Android apps developmentAndroid apps development
Android apps developmentRaman Pandey
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorialnirajsimulanis
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development BasicMonir Zzaman
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development pptsaitej15
 
Android deep dive
Android deep diveAndroid deep dive
Android deep diveAnuSahniNCI
 
Technology and Android.pptx
Technology and Android.pptxTechnology and Android.pptx
Technology and Android.pptxmuthulakshmi cse
 
Getting started with android programming
Getting started with android programmingGetting started with android programming
Getting started with android programmingPERKYTORIALS
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Androidguest213e237
 
5 beginner android application development foundation
5 beginner android application development foundation5 beginner android application development foundation
5 beginner android application development foundationCbitss Technologies
 
Hello android world
Hello android worldHello android world
Hello android worldeleksdev
 
Android developer interview questions with answers pdf
Android developer interview questions with answers pdfAndroid developer interview questions with answers pdf
Android developer interview questions with answers pdfazlist247
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1Isham Rashik
 

Semelhante a Android Introduction (20)

Android apps development
Android apps developmentAndroid apps development
Android apps development
 
Android
AndroidAndroid
Android
 
Android Basic- CMC
Android Basic- CMCAndroid Basic- CMC
Android Basic- CMC
 
Notes Unit3.pptx
Notes Unit3.pptxNotes Unit3.pptx
Notes Unit3.pptx
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Android development-tutorial
Android development-tutorialAndroid development-tutorial
Android development-tutorial
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Android Apps Development Basic
Android Apps Development BasicAndroid Apps Development Basic
Android Apps Development Basic
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 
GDG School Android Workshop
GDG School Android WorkshopGDG School Android Workshop
GDG School Android Workshop
 
Android app development
Android app developmentAndroid app development
Android app development
 
Android app development
Android app developmentAndroid app development
Android app development
 
Android deep dive
Android deep diveAndroid deep dive
Android deep dive
 
Technology and Android.pptx
Technology and Android.pptxTechnology and Android.pptx
Technology and Android.pptx
 
Getting started with android programming
Getting started with android programmingGetting started with android programming
Getting started with android programming
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
 
5 beginner android application development foundation
5 beginner android application development foundation5 beginner android application development foundation
5 beginner android application development foundation
 
Hello android world
Hello android worldHello android world
Hello android world
 
Android developer interview questions with answers pdf
Android developer interview questions with answers pdfAndroid developer interview questions with answers pdf
Android developer interview questions with answers pdf
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 

Mais de Daniela Da Cruz

Introduction to iOS and Objective-C
Introduction to iOS and Objective-CIntroduction to iOS and Objective-C
Introduction to iOS and Objective-CDaniela Da Cruz
 
Game Development with AndEngine
Game Development with AndEngineGame Development with AndEngine
Game Development with AndEngineDaniela Da Cruz
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsDaniela Da Cruz
 
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Daniela Da Cruz
 
Android Introduction - Lesson 1
Android Introduction - Lesson 1Android Introduction - Lesson 1
Android Introduction - Lesson 1Daniela Da Cruz
 

Mais de Daniela Da Cruz (7)

Introduction to iOS and Objective-C
Introduction to iOS and Objective-CIntroduction to iOS and Objective-C
Introduction to iOS and Objective-C
 
Games Concepts
Games ConceptsGames Concepts
Games Concepts
 
C basics
C basicsC basics
C basics
 
Game Development with AndEngine
Game Development with AndEngineGame Development with AndEngine
Game Development with AndEngine
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical Systems
 
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
 
Android Introduction - Lesson 1
Android Introduction - Lesson 1Android Introduction - Lesson 1
Android Introduction - Lesson 1
 

Último

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Android Introduction

  • 1. Android Programming Daniela da Cruz Instituto Politécnico do Cávado e do Ave III Jornadas de Tecnologia May 6, 2013 1 of 14
  • 2. The Story Advantages of using Android Disadvantages of using Android What will be done along this workshop? How to start programming? 2 of 14
  • 3. The Story - Android is a is a Linux-based operating system for smartphones and tablets created by Google. - Developers write applications in a customized version of Java, and apps can be downloaded from online stores such as Google Play (formerly Android Market), the app store run by Google, or third-party sites. - In June 2012, there were more than 600 000 apps available for Android, and the estimated number of applications downloaded from Google Play was 20 billion (according to http://www.engadget.com). 3 of 14
  • 10. Advantages of using Android • The Android OS is simple to learn, and Google provides many libraries to make it easy to implement rich and complex applications • Multitasking: Android phones can run many applications, it means you can browse Facebook while listening a song. • Easy access to thousands of applications via the Google Android App Market. • Phone options are diverse: dierent from iOS that is limited to iPhone from Apple, Android is available on mobile phones from various manufacturers (Sony Ericsson, Motorola, HTC to Samsung). 10 of 14
  • 11. Disadvantages of using Android • The only aspect lacking, as mentioned by many in the Android developer community, is clear and well-explained documentation. • Advertising: application in the Android phones can indeed be obtained easily and for free, but the consequences in each of these applications, will always be ads on display, either the top or bottom of the application. 11 of 14
  • 12. What will be done in this workshop? • The classical Hello World! • Take a pic and show it in our app • Show a Google Map and change its center using our location 12 of 14
  • 13. How to start programming? • Download and install the Android SDK (4.2 version - Jelly Bean) it provides the API libraries and developer tools necessary to build, test, and debug apps for Android. Details on http://developer.android.com/sdk/index.html Pre-requisites: • Eclipse 3.6.2 (Helios) or greater • Eclipse JDT plugin (included in most Eclipse IDE packages) • JDK 6 (JRE alone is not sucient) • Android Development Tools plugin (recommended) 13 of 14
  • 14. Android Application Overview Activity Lifecycle Basic Android User Interface components Activity Fragments View and ViewGroup Layouts AbsoluteLayout FrameLayout LinearLayout RelativeLayout TableLayout XML Layout Attributes Dimensions 2 of 20
  • 15. Android Application Overview An Android application consists of various functionalities. Some examples are editing a note, playing a music file, ringing an alarm, or opening a phone contact.These functionalities can be classified into four different Android components: Every application is made up of one or more of these components. 3 of 20
  • 17. Activity Lifecycle Note the following: • Changing the screen orientation destroys and recreates the activity from scratch. • Pressing the Home button pauses the activity, but does not destroy it. • Pressing the Application icon might start a new instance of the activity, even if the old one was not destroyed. • Letting the screen sleep pauses the activity and the screen awakening resumes it. (This is similar to taking an incoming phone call.) 5 of 20
  • 18. Activity An Activity represents the visual representation of an Android application. Activities use Views and Fragments to create the user interface and to interact with the user. An Android application can have several Activities. 6 of 20
  • 19. Fragments Fragments are components which run in the context of an Activity. Fragment components encapsulate application code so that it is easier to reuse it and to support different sized devices. Fragments are optional, you can use Views and ViewGroups directly in an Activity but in professional applications you always use them to allow the reuse of your user interface components on different sized devices. 7 of 20
  • 20. View and ViewGroup Views are user interface widgets, e.g. buttons or text fields. The base class for all Views is the android.view.View class. Views have attributes which can be used to configure their appearance and behavior. A ViewGroup is responsible for arranging other Views. ViewGroups is also called layout managers. The base class for these layout managers is the android.view.ViewGroup class which extends the View class. ViewGroups can be nestled to create complex layouts. You should not nestle ViewGroups too deeply as this has a negative impact on the performance. 8 of 20
  • 21. View and ViewGroup The user interface for each component of your app is defined using a hierarchy of View and ViewGroup objects. The easiest and most effective way to define a layout is with an XML file. 9 of 20
  • 22. Layouts An Android layout is a class that handles arranging the way its children appear on the screen. Anything that is a View (or inherits from View) can be a child of a layout. All of the layouts inherit from ViewGroup (which inherits from View) so you can nest layouts. The standard Layouts are: • AbsoluteLayout • FrameLayout • LinearLayout • RelativeLayout • TableLayout 10 of 20
  • 23. XML Layout Attributes At compile time, references to the resources are gathered into an auto-generated wrapper class called R.java. The Android Asset Packaging Tool (aapt) autogenerates this file. The syntax for an ID, inside an XML tag is: android:id=@+id/my_button The at-symbol (@) at the beginning of the string indicates that the XML parser should parse and expand the rest of the ID string and identify it as an ID resource. The plus-symbol (+) means that this is a new resource name that must be created and added to the R.java file. 16 of 20
  • 24. XML Layout Attributes When referencing an Android resource ID, you do not need the plus-symbol, but must add the android package namespace, like so: android:id=@android:id/empty With the android package namespace in place, we’re now referencing an ID from the android.R resources class, rather than the local resources class. 17 of 20
  • 25. XML Layout Attributes In order to create views and reference them from the application, a common pattern is to: 1. Define a view/widget in the layout file and assign it a unique ID: Button android:id=@+id/my_button android:layout_width=wrap_content android:layout_height=wrap_content android:text=@string/my_button_text/ 18 of 20
  • 26. XML Layout Attributes In order to create views and reference them from the application, a common pattern is to: 2. Then create an instance of the view object and capture it from the layout (typically in the onCreate() method): Button myButton = (Button) findViewById(R.id.my_bu Defining IDs for view objects is important when creating a RelativeLayout. In a relative layout, sibling views can define their layout relative to another sibling view, which is referenced by the unique ID. 19 of 20
  • 27. Dimensions A dimension is specified with a number followed by a unit of measure. The following units of measure are supported by Android: • dp — Density-independent Pixels: An abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, on which 1dp is roughly equal to 1px. When running on a higher density screen, the number of pixels used to draw 1dp is scaled up by a factor appropriate for the screen’s dpi. • sp — Scale-independent Pixels: This is like the dp unit, but it is also scaled by the user’s font size preference. • pt — Points: 1/72 of an inch based on the physical size of the screen. 20 of 20
  • 28. Dimensions A dimension is specified with a number followed by a unit of measure. The following units of measure are supported by Android: • px — Pixels: Corresponds to actual pixels on the screen. This unit of measure is not recommended because the actual representation can vary across devices. • mm — Millimeters: Based on the physical size of the screen. • in — Inches: Based on the physical size of the screen. 21 of 20
  • 29. Intents Explicit Intents Implicit Intents Using Intents to call Activities Calling Sub-Activities for result data 2 of 8
  • 30. Intents Intents are asynchronous messages which allow Android components to request functionality from other components of the Android system. For example an Activity can send an Intents to the Android system which starts another Activity. An Intent can also contain data. This data can be used by the receiving component. There are two types of Intents: Explit and Implict. 3 of 8
  • 31. Explicit Intents Explicit Intents explicitly defines the component which should be called by the Android system, by using the Java class as identifier. The following shows an explicit Intent. Explicit Intents are typically used within on application as the classes in an application are controlled by the application developer. 4 of 8
  • 32. Implicit Intents Implicit Intents do not directly specify the Android components which should be called. For example the following tells the Android system to view a webpage. If these Intents are send to the Android system it searches for all components which are registered for the specific action and the data type. If only one component is found, Android starts this component directly. If several components are identifier by the Android system, the user will get an selection dialog and can decide which component should be used for the Intent. 5 of 8
  • 33. Retrieving data from Intents The component which receives the Intent can use the getIntent().getExtras() method call to get the extra data. 6 of 8
  • 34. Using Intents to call Activities If you send an Intent to the Android system, Android requires that you tell it to which type of component your Intent should be send. To start an Activity use the method startActivity(Intent). This method is defined on the Context object and available in every Activity object. If you call an Activity with the startActivity(Intent) method the caller requires no result from the called Activity. 7 of 8
  • 35. Calling Sub-Activities for result data If you need some information from the called Activity use the startActivityForResult() method. If you use the startActivityForResult() method then the started Activity is called a Sub-Activity. 8 of 8
  • 36. Bibliography • Android - Introdução ao Desenvolvimento de Aplicações, Ricardo Queirós (Abril 2013). • Programming Android. Zigurd Mednieks, Laird Dornin, G. Blake Meike, Masumi Nakamura. O'Reilly Media. July 2011 • The Android Developer's Cookbook: Building Applications with the Android SDK. James Steele, Nelson To. • http://www.learn-android.com • http://www.vogela.com 14 of 14