SlideShare uma empresa Scribd logo
1 de 91
Baixar para ler offline
Intro to programming
with Androids



@MaksimGolivkin
Android dev @Uber
Plan
 •  Brave mobile world
 •  Daily life-cycle
 •  Different screens
 •  Hybrid applications
Why “mobile” development?
In developing world
And in the most posh economies.
Smartphones, tablets and more
Only an Internet device?
What smart devices are made of?
Memory           Ports       Positioning    Radios           Sensors
Build-­‐in	
     Audio	
     Cellular	
     Mobile	
  	
     Audio	
  
SD	
  card	
     USB	
       GPS	
          Wi-­‐Fi	
        Photo/video	
  
                 HDMI	
      Wi-­‐Fi	
      Bluetooth	
      Light	
  
                             A-­‐GPS	
      NFC	
            AcceleraBon	
  
                                                             MagneBc	
  
                                                             Gyroscope	
  
                                                             Proximity	
  



     … Flash, Stylo, Second Screen
Dongle empowering 3 billion $ business
Why Android?
Android creates
a sweet choice.
Open mobile computing platform
Android accounts for
64% in smartphones
40% in tablets	
  




      of device sales in 2012 Q3
GooGPS show-case
Two big butts
 •  App profitability 1/6 of iOS
 •  Fragmentation
Summary
•  Dawn of connected devices era.
•  HW knowledge creates opportunities.
•  Android is leading it.
Android OS
Designed for fast switching between apps
Applications “talk” between each other
There is always a Back button
Programming Android
APIs
 •  SDK   – Java applications
 •  NDK   – mostly games
 •  Hybrid – everybody should
Tools
 •  Eclipse
 •  Eclipse ADT plugin
 •  Android SDK
 •  USB drivers
Learn Android
•  d.android.com
•  stackoverflow.com

•  AppDemo sample application
•  youtube for Google I/O

•  Android OS source code
•  grepcode.com

Books!
Script vs. Application
uber.com                Init



                        Process




   Display              Output


                         Die
PHP script life-cycle
Init


  Interact

                 State   Process

   Display

                          Die



Application life-cycle
Screen
~= Activity
In Memory   Foreground

Launch     Created



                       Resumed

Interact



Press
           Stopped
Home
In Memory   Visible   Foreground

Launch     Created
                       Started

                                 Resumed

Interact

 Open
 other
Activity               Paused
           Stopped
In Memory   Visible   Foreground

Re-Launch               Started

                                  Resumed

 Interact

  Press
  Home

                        Paused

            Stopped
Activities Stack (briefly)
1 st

Screen




1.     Resumed
2 nd

Screen



2.     Resumed

1.     Stopped
3 rd

Screen

3.     Resumed


2.     Stopped

1.     Stopped
Closes an application


Delegates responsibility
Pressing
Back

3.   Resumed

2.   Stopped

1.   Stopped
Destroying
last
activity


2.   Resumed

1.   Stopped
Pressing
Home

3.   Resumed


2.   Stopped

1.   Stopped
Stops
everything

3.   Stopped

2.   Stopped

1.   Stopped
Returned
to the
app
3.   Resumed

2.   Stopped

1.   Stopped
Running
In The
Background?
 … not all of them
Maintaining state
Activity/app life-time
 •  Parameters
 + Saved Instance State


 •  Singleton


 Singleton is king. Mind the GC!
Persistence
 •  Shared Preferences
 •  Files
 •  Server
 •  SQLite


 Do you really need it?
Service
Use cases
•  Long actions in between activities
•  Notifications, when app is dead
•  Intensive calculations


Consider simply using Threads. Twice!
Fragments
Fragments enable multi-pane layouts
Resources
Life
of an image
Using resources
Resources r = getResources();

Drawable d =
   r.getDrawable(R.drawable.ic_american_express);

ImageView icon =
  (ImageView) findViewById(R.layout.card_logo);

icon.setDrawable(d);
Drawable vs. View
Screen
~= Activity

Everything
else
~= Views
Summary (Android OS)
•  Android is popular but poor, yet


•  Learn life-cycle by heart


•  Assess feasibility of Persistence and
 Services. Twice.
Many screens
Different
resolutions




     320x480 px   1280x720 px
Same
physical size



42 dp
Screen density


                     pixel _ width 2 + pixel _ height 2
screen _ density =
                         diagonal _ in _ inches
Many resolutions
    320x426     legacy phones
    240x320     legacy phones
    320x533     legacy phones
    320x576
    320x480     phones
    320x533     phones
    320x568
    320x480     new phones
    360x640
    400x640
    640x1067    tweener tablets
    640x1138
    480x800     tweener tablets
    480x854
    600x1024
    1024x768    tablets
    1280x768
    1280x800
      ...	
  
Landscape
is yet another
resolution
Patterns
Stretching
Adding margins
Multi-pane
Switch points
Switch points

             Home base
  240dp         320dp   360dp   400dp 426dp   480dp    533dp 568dp 578dp   640dp



small size portrait   small size landscape            normal size landscape
                      normal size portrait            large size portrait




          resized elements
          margins added
          switch point (another layout)
Expensive way
                                                                      Boom!


             Home base
  240dp         320dp   360dp   400dp 426dp   480dp    533dp 568dp 578dp   640dp



small size portrait   small size landscape            normal size landscape
                      normal size portrait            large size portrait




          resized elements
          margins added
          switch point (another layout)
Prepairing graphics
Density buckets

ldpi (low)           100 ~ 140 dp
mdpi (medium)        140 ~ 200 dp
hdpi (high)          200 ~ 280 dp
xhdpi (extra high)   280 ~ 340 dp
1 dp = ? px



ldpi    0.75
mdpi    1
hdpi    1.5
xhdpi   2
Nine-patch
 Resizable area




                  Content area
Nine patch
 •  Buttons
 •  Backgrounds
Summary (Many screens)
•  Needs investment, but little surprise.


•  One layout for a start.


•  Resolution ignorance is ugly,
 but not ineffective.
Hybrid apps
“Our biggest mistake was betting
  too much on HTML5”, - Mark Zuckerberg
HTML5 reality in 2012
Hybrid champion:
LinkedIn

    Native

    HTML/CSS	
  



    Native
Hybrid architecture

  Native


  JavaScript API


  HTML/CSS/
  JavaScript
Native side
 WebView webView = (WebView)
   findViewByid(R.id.webview);

 webView.addJavascriptInterface(obj, "Android");

 final String html = AssetUtil.readAssetsFile(
     context, filename);

 webView.loadDataWithBaseURL(
   "file://", html, "text/html","utf-8", null);
JavaScript side
 function onClick() {

     Android. jsOnNextArticle(this.id);
 }
“API” glue
public void showArticle(long id, String content) {

     webView.loadUrl("javascript: jsShowArticle(" + id
       + ", " + Uri.encode(content) + "");")
}

..

public void jsOnNextArticle(long articleId) {
  …

}
“API” glue
public void showArticle(long id, String content) {

     webView.loadUrl("javascript: jsShowArticle(" + id
       + ", " + Uri.encode(content) + "");")
}

..

public void jsOnNextArticle(long articleId) {
  …

}
Summary (Hybrid apps)
•  Content centered apps
•  FAQ, User License, …
•  1-1.5x more effort than native
•  Pays of when targeting >= 3 platforms
Read ON
-  The real problem with Android fragmentation

-  Where does Android fragmentation hide?

-  The technical adventure building a hybrid app.

-  Fast track to Android design.



       Interested in Android?        @MaksimGolivkin
       Care to give feedback?      maksim@golivkin.eu

Mais conteúdo relacionado

Mais procurados (7)

The story of MSQRD
The story of MSQRDThe story of MSQRD
The story of MSQRD
 
Android design lecture #3
Android design   lecture #3Android design   lecture #3
Android design lecture #3
 
Android design lecture #1
Android design   lecture #1Android design   lecture #1
Android design lecture #1
 
Google Cardboard and VR Tips (at KL)
Google Cardboard and VR Tips (at KL)Google Cardboard and VR Tips (at KL)
Google Cardboard and VR Tips (at KL)
 
Synthetic environment
Synthetic environmentSynthetic environment
Synthetic environment
 
Wearable Technologies - Devfest Oran 2015
Wearable Technologies - Devfest Oran 2015Wearable Technologies - Devfest Oran 2015
Wearable Technologies - Devfest Oran 2015
 
Exploring Microsoft Surface
Exploring Microsoft SurfaceExploring Microsoft Surface
Exploring Microsoft Surface
 

Destaque

Destaque (7)

Mobile Programming LLC sample Case Studies
Mobile Programming LLC sample Case StudiesMobile Programming LLC sample Case Studies
Mobile Programming LLC sample Case Studies
 
Mobile Programming Services
Mobile Programming ServicesMobile Programming Services
Mobile Programming Services
 
Oeb09 Session1 Basic To Mobile20
Oeb09 Session1 Basic To Mobile20Oeb09 Session1 Basic To Mobile20
Oeb09 Session1 Basic To Mobile20
 
Creating mobile apps - an introduction to Ionic (Engage 2016)
Creating mobile apps - an introduction to Ionic (Engage 2016)Creating mobile apps - an introduction to Ionic (Engage 2016)
Creating mobile apps - an introduction to Ionic (Engage 2016)
 
Introduction to PhoneGap
Introduction to PhoneGapIntroduction to PhoneGap
Introduction to PhoneGap
 
Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Semelhante a Introduction to mobile programming with Androids.

Philly ete-2011
Philly ete-2011Philly ete-2011
Philly ete-2011
davyjones
 
콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석
Jaehyeuk Oh
 
Applico Android Info Session at Columbia University
Applico Android Info Session at Columbia UniversityApplico Android Info Session at Columbia University
Applico Android Info Session at Columbia University
Applico
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
Imam Raza
 
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There TodayHTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
davyjones
 
Beating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett DuncavageBeating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett Duncavage
Xamarin
 

Semelhante a Introduction to mobile programming with Androids. (20)

Supporting multi screen in android cn
Supporting multi screen in android cnSupporting multi screen in android cn
Supporting multi screen in android cn
 
How to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidHow to deal with Fragmentation on Android
How to deal with Fragmentation on Android
 
Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐Android在多屏幕、多设备上的适配 | 布丁 任斐
Android在多屏幕、多设备上的适配 | 布丁 任斐
 
Philly ete-2011
Philly ete-2011Philly ete-2011
Philly ete-2011
 
UI and UX for Mobile Developers
UI and UX for Mobile DevelopersUI and UX for Mobile Developers
UI and UX for Mobile Developers
 
콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석콘텐츠 플랫폼 구조 분석
콘텐츠 플랫폼 구조 분석
 
Android training day 3
Android training day 3Android training day 3
Android training day 3
 
Android development first steps
Android development   first stepsAndroid development   first steps
Android development first steps
 
Applico Android Info Session at Columbia University
Applico Android Info Session at Columbia UniversityApplico Android Info Session at Columbia University
Applico Android Info Session at Columbia University
 
Javaland 2014 / GWT architectures and lessons learned
Javaland 2014 / GWT architectures and lessons learnedJavaland 2014 / GWT architectures and lessons learned
Javaland 2014 / GWT architectures and lessons learned
 
Gup web mobilegis
Gup web mobilegisGup web mobilegis
Gup web mobilegis
 
Android v 1.1
Android v 1.1Android v 1.1
Android v 1.1
 
Android Lollipop: The developer's perspective
Android Lollipop: The developer's perspectiveAndroid Lollipop: The developer's perspective
Android Lollipop: The developer's perspective
 
Google Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talkGoogle Developer Group(GDG) DevFest Event 2012 Android talk
Google Developer Group(GDG) DevFest Event 2012 Android talk
 
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There TodayHTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009
 
Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Land...
Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Land...Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Land...
Xamarin Evolve 2014 - Designing Android UIs for the Ever Changing Device Land...
 
Beating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett DuncavageBeating Android Fragmentation, Brett Duncavage
Beating Android Fragmentation, Brett Duncavage
 
Multi Channel Publishing
Multi Channel PublishingMulti Channel Publishing
Multi Channel Publishing
 
Game design & development
Game design & developmentGame design & development
Game design & development
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Introduction to mobile programming with Androids.