• Save
[Droidcon]Developing Apps for Android on 2.x/3.x/4.x
Upcoming SlideShare
Loading in...5
×
 

[Droidcon]Developing Apps for Android on 2.x/3.x/4.x

on

  • 2,348 views

"Developing Apps for Android on 2.x/3.x/4.x"

"Developing Apps for Android on 2.x/3.x/4.x"
->The presentation file on droidcon London 2012

Statistics

Views

Total Views
2,348
Views on SlideShare
1,344
Embed Views
1,004

Actions

Likes
8
Downloads
0
Comments
0

7 Embeds 1,004

http://d.hatena.ne.jp 722
http://www.iplatform.org 249
http://webcache.googleusercontent.com 20
http://hatenatunnel.appspot.com 5
https://twitter.com 3
http://translate.googleusercontent.com 3
https://www.google.co.jp 2
More...

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

[Droidcon]Developing Apps for Android on 2.x/3.x/4.x [Droidcon]Developing Apps for Android on 2.x/3.x/4.x Presentation Transcript

  • Droidcon London 2012 Developing Apps for Android on 2.x/3.x/4.x Kenichi Kambara (@korodroid) October 26, 2012
  • Who am I? l  Kenichi Kambara (Twitter @korodroid)l  iplatform.org(http://www.iplatform.org/) (Personal)l  NTT Software Corporation (Official)l  Activity(iplatform.org as Personal)     -  My Android Apps on Google Play (20+ Apps) 9 10 2
  • Who am I? l  Kenichi Kambara (Twitter @korodroid)l  iplatform.org(http://www.iplatform.org/) (Personal)l  NTT Software Corporation (Official)l  Activity(iplatform.org as Personal)     -  My Android Apps on Google Play (20+ Apps) 9 10“Sekai Phone” l Google Developer Day 2011 Tokyo Keynote Demo l Google Android Developer Lab Tokyo 2011 5th prize 3
  • Agenda • Introduction • Background • Android Fundamentals • Application Development Tips 4
  • My session topics Some tips on developing Apps for multi versions and multi devices.2.x 3.x 4.x Handsets Tablets 5
  • Introduction(Sekai Phone) 6
  • What is “Sekai Phone”? Real time translation phone services(Supports Android 2.x/3.x/4.x & multi devices) ) English German Japanese ○ ○ ○ Italian French ○ ○ Chinese Publishe Date: Jan, 2010, over 20+ ver.up 7
  • Use Case (1) Phone mode(Auto translating to receiver’s native language) English Japanese Hello! Talking Konnichiwa! Talking Paul Kenichi Thanks! Arigatou! 8
  • Use Case (2) Talk mode (Auto translating on the spot) English Japanese 9
  • App Demos (1.Phone mode) English Japanese Hello! Talking Konnichiwa! Talking Paul Kenichi Thanks! Arigatou! 10
  • App Demos (2.Talk mode) 11
  • App Screenshots on Android 2.x Portrait Landscape 12
  • App Screenshots on Android 3.x Portrait Landscape 13
  • App Screenshots on Android 4.x Portrait Landscape 14
  • Background 15
  • Current Android Devices Handsets Handsets (Almost all) & Tablets2.x Tablets 4.x (All)3.x 16
  • Platform Versions? This data by Google on October 1, 2012 17
  • Platform Versions? Honeycomb ICS JB Gingerbread Others Froyo This data by Google on October 1, 2012 In my App: Main Target: Android 2.2+ (2.2,2.3,3.x,4.x) 18
  • Screen Sizes & Densities? xhdpi Normal Small ldpi Xlarge hdpi Large mdpi This data by Google on October 1, 2012 19
  • Screen Sizes & Densities? This data by Google on October 1, 2012 In my App: Main Target: (normal,large,xlarge)x(mdpi,hdpi,xhdpi) 20
  • Android Fundamentals 21
  • Fragment? Handset Tablet Activity A Activity B Activity A 22
  • Fragment? Handset Tablet Fragment X Fragment Y Fragment X Fragment YActivity A Activity B Activity A 23
  • Menu? Options Menu Action Bar (2.x) (3.0+) 24
  • Application Development Tips 25
  • Support multi versions and multi devices? 1.Designing User Interface l  Screen size l  Screen density l  Screen orientation …2.Using APIs l  Fragment l  Menu … 26
  • 1.  Designing User Interface [Some Approaches] 27
  • [UI]1 st Approach Using layout-small/normal/large/xlargeScreen Size Classification l  Supports Android 1.6+ l  Both 7” tablet and 5” handset mapped to “large” l  Pre 3.0 some devices mis-classified 28
  • [UI]Introduction of 2nd Approach Using “dp(Density-Independent pixel)”Width sizes Devices 320dp Typical Handsets 600dp 7” tablet 720dp 10” tablet 29
  • [UI]2 nd Approach e.g.)Supporting Handsets & 2 TabletsHandsets 7’’ Tablet 10’’ Tablet l  res/layout/main.xml l  res/layout-sw600dp/main.xml l  res/layout-sw720dp/main.xml 30
  • [UI]2 nd Approach sw<N>dp?, w<N>dp?, h<N>dp?(a)layout-sw600dp Width & Height ≥ 600dp(b)layout-w720dp Width ≥ 720dp (c)layout-h480dp Height ≥ 480dp 31
  • [UI]2 nd Approach Using sw<N>dp,w<N>dp,h<N>dp400 dp 960 dp (a)layout-sw600dp false (b)layout-w720dp true (c)layout-h480dp false 32
  • [UI]2 nd Approach Using sw<N>dp,w<N>dp,h<N>dp(a)layout-sw600dp Width & Height ≥ 600dp(b)layout-w720dp Width ≥ 720dp (c)layout-h480dp Height ≥ 480dp l  Recommended by Google l  Supports only Android 3.2+ Note: Effect by Screen Orientation 33
  • [UI]3 rd Approach Combination of 1st and 2ndl  res/layout-sw600dp/main.xml <- 3.2+ tablets l  res/layout-xlarge/main.xml <- 3.0/3.1 tabletsl  res/layout/main.xml <- The others (Handsets)l  Supports Android 1.6l  Supports many devices (compared to 1st or 2nd)l  Any Problem? 34
  • [UI]3 rd Approach It looks good but…l  res/layout-sw600dp/main.xml <- 3.2+ tablets l  res/layout-xlarge/main.xml <- 3.0/3.1 tabletsl  res/layout/main.xml <- The others (Handsets) •  Needs to put the same file for tablets. (Maintenance headache…) 35
  • [UI]3 rd Approach It looks good but…if ([Size is xlarge] or [width & height is at least 600dp]) // codes for tablets}else{ // codes for others} •  Complicated Java codes (Development is complicated…) 36
  • Which is the Better Approach? 37
  • [UI]4 th Approach Based on 3rd , plus some tips•  Put minimum requirement for layouts 38
  • [UI]4 th Approach Based on 3rd , plus some tips (Layout Aliases) // for Tablets <resources> <item name "main_layout" type="layout"> @layout/main_twopanes </item> <bool name="has_two_panes"> true </bool> </resources> 39
  • [UI]4 th Approach Based on 3rd , plus some tips (Layout Aliases)// for Tablets <resources> <item name "main_layout" type="layout"> @layout/main_twopanes </item> <bool name="has_two_panes"> true </bool> </resources> boolean hasTwoPanes =getResources(). getBoolean(R.bool.has_two_panes); if (hasTwoPanes) … •  Simple Java codes 40
  • 2.Using APIs? [Some Points] 41
  • [API]Fragment Using Support Library? 2.x 3.x 4.x WithoutSupport Library WithSupport Library 42
  • [API]Fragment Comparing Using with No-Using With Without Support Library Support Library • android.support.v4.Fragment • android.app.Fragment Class • android.support.v4.FragmentActivity • android.app.Activity … … • getSupportFragmentManager() • getFragmentManager()Method (FragmentActivity) (Activity) … … 43
  • [API]Options Menu vs Action Bar Action Bar is good… 2.x 3.x 4.x Options Menu Action Bar Note: ActionBarSherlock lib, Effect by style 44
  • [API]Effect by AndroidManifest On Android 2.x / 3.x Min Target 2.x 3.x Sdk Sdk Pattern 1 - -   (Fail 1)Pattern 2 8 8   (Fail 2)Pattern 3 8 16 Fail 2 Fail 1 45
  • [API]Effect by AndroidManifest On Android 2.x / 4.x Min Target 2.x 4.x Sdk Sdk Pattern 1 - -   (Fail 3)Pattern 2 8 8   (Fail 4)Pattern 3 8 16 Fail 3 Fail 4 46
  • [API]Effect by AndroidManifest On Android 2.x / 3.x / 4.x Min Target 2.x 3.x 4.x Sdk Sdk Pattern 1 - - Pattern 2 8 8 Pattern 3 8 16 4.x 2.x 3.x 47
  • [API]Effect by AndroidManifest On Android 2.x / 3.x / 4.x Min Target 2.x 3.x 4.x Sdk Sdk Pattern 1 - - Pattern 2 8 8 Pattern 3 8 16 Note: Google Official blogs, Split Action Bar 48
  • [API]Multi-Versioning Development?, Management?, APK Size?Single APK Multiple APK 49
  • [API]Multi-Versioning Single APK In my App: Developed by Single APK 50
  • [API]Multi-Versioning How to use the newest API on Single APK Reflection Well known approach Lazy loading One of Design Patterns 51
  • [API]Multi-Versioning How to use the newest API on Single APK Reflection Well known approach Lazy loading One of Design Patterns In my App: Compatibility with Lazy loading 52
  • [API]Multi-Versioning Code Examples of Lazy loading1 st step public abstract class NotificationUtilAbstract { public static NotificationUtilAbstract newInstance() { NotificationUtilAbstract instance = null; if (Integer.parseInt(Build.VERSION.SDK)>= 16) { instance = new NotificationUtilJB(); } else { instance = new NotificationUtilDefault(); } return instance; } public abstract void showCaller; } 53
  • [API]Multi-Versioning 2 nd step public class NotificationUtilJB
 extends NotificationUtilAbstract{
 @Override
 public void showCaller(){ // Code by Jelly Bean (API 16) } } public class NotificationUtilDefault
 extends NotificationUtilAbstract{
 @Override
 public void showCaller(){ // Code by Old API } •  Compatible } 54
  • Appendix 1.  Use “wrap_content”/“match_parent”,”sp”/”dp”   2.  Supply alternative drawables / Use 9-patch 3.  Use Fragment 4.  Use “Dimension (Customize component size)” 5.  Consider either “1 apk” or “multiple apk” 55
  • References Android Developers Site• Supporting Tablets and Handsets http://developer.android.com/guide/practices/tablets-and-handsets.html • Supporting Multiple Screens http://developer.android.com/guide/practices/screens_support.html  • Supporting Different Screen Sizes http://developer.android.com/training/multiscreen/screensizes.html  56
  • References“Android Programming Nyumon v2” •  Language: Japanese (Sorry…) •  Release Date: August 30, 2012 •  Publisher:ASCII MEDIA WORKS Inc. •  Authors: - Takashi Egawa - Kenichi Kambara - Akimichi Yamada - Tetsurou Sano - Mariko Goda 57
  • Thank you!• Facebook:http://fb.com/kanbara.kenichi• Google+:+Kenichi Kambara • Twitter:@korodroid