• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
[Droidcon Paris 2013]Multi-Versioning Android Tips
 

[Droidcon Paris 2013]Multi-Versioning Android Tips

on

  • 1,090 views

This is my presentation file on Droidcon Paris 2013.

This is my presentation file on Droidcon Paris 2013.

Statistics

Views

Total Views
1,090
Views on SlideShare
705
Embed Views
385

Actions

Likes
1
Downloads
0
Comments
0

4 Embeds 385

http://www.iplatform.org 237
http://fr.droidcon.com 82
http://www.wipconnector.com 62
http://blog.iplatform.org 4

Accessibility

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 Paris 2013]Multi-Versioning Android Tips [Droidcon Paris 2013]Multi-Versioning Android Tips Presentation Transcript

    • Multi-Versioning Android AppsDroidcon Paris 2013Kenichi Kambara (@korodroid)June 18, 2013
    • l Kenichi Kambara (Twitter @korodroid)l iplatform.org(http://www.iplatform.org/) (Personal)l NTT Software Corporation (Official)2l Activity(iplatform.org as Personal)    9 10Who am I?- My Android Apps on Google Play (20+ Apps)l Activity(NTT Software as Official)    - Technical Support for Developing
    • 3l Kenichi Kambara (Twitter @korodroid)l iplatform.org(http://www.iplatform.org/) (Personal)l NTT Software Corporation (Official)Who am I?l Activity(iplatform.org as Personal)    9 10“Sekai Phone”lGoogle Developer Day 2011 Tokyo Keynote DemolMulti Screen UX Competition 2013 Excellence AwardslMobile World Congress 2013 Exhibition
    • 4l Kenichi Kambara (Twitter @korodroid)l iplatform.org(http://www.iplatform.org/) (Personal)l NTT Software Corporation (Official)Who am I?l Activity(iplatform.org as Personal)    New Sekai PhoneAvailable Today!!!*Special Thanks: Kenichi TakahashilImproved UI / UXlImproved UsabilitylMultiVersions & Devices
    • 5Agenda•Introduction (+ Sekai Phone)•Background•Application Development TipsQ. How to support Multiple Screens?Q. How to support Multiple Versions?
    • 62.x 3.x 4.xMy session topicsSome tips on developing Appsfor multi versions and multi devices.Handsets Tablets
    • 7Introduction(Sekai Phone)
    • 8What is “Sekai Phone”?ChineseJapaneseFrenchItalian○English German○ ○○○Real time translation phone services(Supports Android 2.x/3.x/4.x & multi devices)Publish Date: Jan, 2010, over 20+ ver.up
    • 9Use Case (1)Phone mode(Auto translating to receiver’s native language)French Japanese
    • 9Use Case (1)Phone mode(Auto translating to receiver’s native language)Bonjour!French Japanese
    • 9Use Case (1)Phone mode(Auto translating to receiver’s native language)Konnichiwa!Bonjour!French Japanese
    • 9Use Case (1)Phone mode(Auto translating to receiver’s native language)Konnichiwa!Arigatou!Bonjour!French Japanese
    • 9Use Case (1)Phone mode(Auto translating to receiver’s native language)Konnichiwa!Merci! Arigatou!Bonjour!French Japanese
    • 10App Demos (1.Phone mode)N/A
    • 11FrenchEnglishUse Case (2)Talk mode(Auto translating on the spot)
    • 12App Demos (2.Talk mode)
    • 13App Screenshots on Android 2.x/3.x/4.x2.x3.x4.xHandsets Tablets
    • 14Background
    • 15Current Android Devices2.x3.x4.xHandsets(Almost all)Tablets(All)Handsets& Tablets
    • 16PlatformVersions?This data by Google on Feb 1, 2013
    • 17PlatformVersions?In my App:Main Target: Android 2.2+ (2.2,2.3,3.x,4.x)This data by Google on June 3, 2013ICSJBEclairFroyoGingerbreadHoneycomb
    • 18Screen Sizes & Densities?This data by Google on June 3, 2013NormalSmallXlargeLargehdpixhdpildpimdpixxhdpitvdpi
    • 19Screen Sizes & Densities?In my App:My Target: (normal,large,xlarge)x(mdpi,hdpi,xhdpi,xxhdpi)This data by Google on June 3, 2013
    • 20Application Development Tips
    • 21l How to support Multiple ScreensSupport multi versions and multi devices?1.Designing User Interface2.Using APIsl How to support Multiple Versions
    • 221. Designing User Interface[Some Approaches]Handsets Tablet (‘’7) Tablet (‘’10)
    • 23[UI]1st ApproachUsing layout-small/normal/large/xlargel Supports Android 1.6+l Some ProblemScreen SizeClassification
    • 24[UI]Introduction of 2nd ApproachRemarking “dp(Density-Independent pixel)”HandsetsTypically, Width & Height ≥ 600dpTablet (‘’7)
    • 25[UI]Introduction of 2nd ApproachUsing “dp(Density-Independent pixel)”Handsets Tablet (‘’7)Typically, Width & Height ≥ 600dplayout/main.xmllayout-sw600dp/main.xml
    • 26[UI]2nd ApproachUsing sw<N>dp,w<N>dp,h<N>dpl Recommended by Googlel Supports only Android 3.2+layout/main.xmlHandsets Tablet (‘’7) Tablet (‘’10)layout-sw600dp/main.xmllayout-sw720dp/main.xml
    • 27[UI]3rd ApproachCombination of 1st and 2ndl Supports Android 1.6l Supports many devices (compared to 1st or 2nd)l Any Problem?l res/layout-sw600dp/main.xml <- 3.2+ tabletsl res/layout-xlarge/main.xml <- 3.0/3.1 tabletsl res/layout/main.xml <- The others (Handsets)
    • 28[UI]3rd ApproachIt looks good but…l res/layout-sw600dp/main.xml <- 3.2+ tabletsl 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…)
    • 29[UI]3rd ApproachIt 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…)
    • 30The better Approach
    • 31[UI]4th ApproachBased on 3rd , plus some tipsl main_1pane.xml <- Handsetsl main_2panes.xml <- TabletslayoutPut minimum requirementlayout files
    • 32[UI]4th Approachl main_1pane.xmll main_2panes.xmllayoutl layout_main.xmlvaluesl layout_main.xmlvalues-sw600dpl layout_main.xmlvalues-xlarge// for Tablets<resources><item name "main_layout" type="layout">@layout/main_2panes</item><bool name="has2panes">true</bool></resources>
    • 33[UI]4th Approach// for Tablets<resources><item name "main_layout" type="layout">@layout/main_2panes</item><bool name="has2panes">true</bool></resources>boolean hasTwoPanes =getResources().getBoolean(R.bool.has2panes);if (hasTwoPanes)…• Simple Java codes
    • 34Another Approach
    • 35[UI]Flexible Layout• Same Layoutfor Handsets & TabletsHandsets TabletsNo-Using Fragment
    • 36Additional Tips
    • <resources><dimen name="titleSize">24sp</dimen></resources><resources><dimen name="titleSize">12sp</dimen></resources>37[UI]Customize font size for different screen• Applying appropriate font sizeHandsets Tablet (‘’7)HelloHelloandroid:textSize=”@dimen/titleSize”Layout XMLvalues/dimens.xmlvalues-sw600dp/dimens.xml
    • 382.Using APIs?[Some Points]Android2.xAndroid3.xAndroid4.x
    • 39[API]Fragment2.x 3.x 4.xWithoutSupport LibraryWithSupport LibraryUsing Support Library?
    • 40[API]FragmentComparing Using with No-UsingWithSupport LibraryWithoutSupport LibraryClass•android.support.v4.Fragment•android.support.v4.FragmentActivity…•android.app.Fragment•android.app.Activity…Method•getSupportFragmentManager()(FragmentActivity)…•getFragmentManager()(Activity)…
    • 41[API]Options Menu vs Action BarAction Bar is good…2.x 3.x 4.xOptions MenuAction Bar2.x 3.x4.x
    • 42[API]Supporting DaydreamDaydream is attractive, but 4.2 APIYour App• 4.2+ devices can run DaydreamOlder devices can run normallyexcept DaydreamXXClassextendsDreamServiceAndroidManifest.xmladdmodify
    • 43[API]Multi-VersioningDevelopment?, Management?, APK Size?Single APK Multiple APKIn my App:Developed by Single APK2.x3.x4.x2.x3.x4.x
    • 44[API]Multi-VersioningHow to use the newest API on Single APKWell known approachReflectionOne of design patterns•SuppressLint("NewApi")•@TargetApi(n)Configuring LintLazy Loading
    • 45[API]Multi-VersioningCode Examples of “Configuring Lint” @SuppressLint("NewApi") private void setActionBarStyle() { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = this.getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); }else{ ... } } @TargetApi(11) private void setActionBarStyle() { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = this.getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); }else{ ... } }Almost Compatible
    • 46[API]Multi-VersioningCode Examples of “Lazy loading”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;}1st step
    • 47[API]Multi-Versioningpublic class NotificationUtilJBextends NotificationUtilAbstract{@Overridepublic void showCaller(){ // Code by Jelly Bean (API 16) }}public class NotificationUtilDefaultextends NotificationUtilAbstract{@Overridepublic void showCaller(){ // Code by Old API }}Compatible2nd step
    • 48[API]Multi-VersioningHow to use the newest API on Single APKWell known approachReflectionIn my App:Compatibility with Lazy loading & Configuring LintOne of design patterns•SuppressLint("NewApi")•@TargetApi(11)Configuring LintLazy Loading
    • 49Appendix1. Use “wrap_content”/“match_parent”,”sp”/”dp” 2. Supply alternative drawables / Use 9-patch3. Using or No-Using Fragment4. Use “Dimension (dimens.xml)”5. Consider either “1 apk” or “multiple apk”
    • 50References•Supporting Tablets and Handsets http://developer.android.com/guide/practices/tablets-and-handsets.html•Supporting Multiple Screenshttp://developer.android.com/guide/practices/screens_support.html•Supporting Different Screen Sizeshttp://developer.android.com/training/multiscreen/screensizes.htmlAndroid Developers Site
    • Thank you!•Facebook:http://fb.com/kanbara.kenichi•Google+:+Kenichi Kambara•LinkedIn:http://www.linkedin.com/in/korodroid•Twitter:@korodroid
    • 52Appendix.Android Fundamentals
    • 53Activity?Handset TabletActivity A Activity B Activity A
    • 54Fragment?Handset TabletActivity A Activity B Activity AFragmentYFragment X Fragment X FragmentY
    • 55Menu?Options Menu(2.x)Action Bar(3.0+)Old Sekai Phone Screenshots