Introduction to mobile programming with Androids.
Upcoming SlideShare
Loading in...5
×
 

Introduction to mobile programming with Androids.

on

  • 1,584 views

Delivered in Kaunas Technical University as part of NFQ academy (http://www.nfq.lt/atviros-paskaitos/)

Delivered in Kaunas Technical University as part of NFQ academy (http://www.nfq.lt/atviros-paskaitos/)

Statistics

Views

Total Views
1,584
Slideshare-icon Views on SlideShare
1,555
Embed Views
29

Actions

Likes
2
Downloads
50
Comments
0

3 Embeds 29

http://www.linkedin.com 21
https://www.linkedin.com 6
https://twitter.com 2

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Introduction to mobile programming with Androids. Introduction to mobile programming with Androids. Presentation Transcript

    • Intro to programmingwith Androids@MaksimGolivkinAndroid 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 SensorsBuild-­‐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 createsa sweet choice.
    • Open mobile computing platform
    • Android accounts for64% in smartphones40% 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.comBooks!
    • Script vs. Application
    • uber.com Init Process Display Output DiePHP script life-cycle
    • Init Interact State Process Display DieApplication life-cycle
    • Screen~= Activity
    • In Memory ForegroundLaunch Created ResumedInteractPress StoppedHome
    • In Memory Visible ForegroundLaunch Created Started ResumedInteract Open otherActivity Paused Stopped
    • In Memory Visible ForegroundRe-Launch Started Resumed Interact Press Home Paused Stopped
    • Activities Stack (briefly)
    • 1 stScreen1. Resumed
    • 2 ndScreen2. Resumed1. Stopped
    • 3 rdScreen3. Resumed2. Stopped1. Stopped
    • Closes an applicationDelegates responsibility
    • PressingBack3. Resumed2. Stopped1. Stopped
    • Destroyinglastactivity2. Resumed1. Stopped
    • PressingHome3. Resumed2. Stopped1. Stopped
    • Stopseverything3. Stopped2. Stopped1. Stopped
    • Returnedto theapp3. Resumed2. Stopped1. Stopped
    • RunningIn TheBackground? … 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 calculationsConsider simply using Threads. Twice!
    • Fragments
    • Fragments enable multi-pane layouts
    • Resources
    • Lifeof an image
    • Using resourcesResources 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~= ActivityEverythingelse~= Views
    • Summary (Android OS)•  Android is popular but poor, yet•  Learn life-cycle by heart•  Assess feasibility of Persistence and Services. Twice.
    • Many screens
    • Differentresolutions 320x480 px 1280x720 px
    • Samephysical size42 dp
    • Screen density pixel _ width 2 + pixel _ height 2screen _ 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 ...  
    • Landscapeis yet anotherresolution
    • Patterns
    • Stretching
    • Adding margins
    • Multi-pane
    • Switch points
    • Switch points Home base 240dp 320dp 360dp 400dp 426dp 480dp 533dp 568dp 578dp 640dpsmall 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 640dpsmall 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 bucketsldpi (low) 100 ~ 140 dpmdpi (medium) 140 ~ 200 dphdpi (high) 200 ~ 280 dpxhdpi (extra high) 280 ~ 340 dp
    • 1 dp = ? pxldpi 0.75mdpi 1hdpi 1.5xhdpi 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” gluepublic void showArticle(long id, String content) { webView.loadUrl("javascript: jsShowArticle(" + id + ", " + Uri.encode(content) + "");")}..public void jsOnNextArticle(long articleId) { …}
    • “API” gluepublic 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