SlideShare uma empresa Scribd logo
1 de 58
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)
                                & Tablets


2.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 Y




Activity 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/xlarge



Screen 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 Tablets




Handsets	

    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>dp



400 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 2nd

l  res/layout-sw600dp/main.xml <- 3.2+ tablets	
l  res/layout-xlarge/main.xml <- 3.0/3.1 tablets
l  res/layout/main.xml <- The others (Handsets)



l  Supports Android 1.6
l  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 tablets
l  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	

  Without
Support Library	

    With
Support 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 loading
1 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

Mais conteúdo relacionado

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

Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids. Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids. Maksim Golivkin
 
Introduction To android
Introduction To androidIntroduction To android
Introduction To androidZaid Khan
 
20130301 mobile os - the future (by empatika.com)
20130301 mobile os - the future (by empatika.com)20130301 mobile os - the future (by empatika.com)
20130301 mobile os - the future (by empatika.com)Empatika
 
Day1 what is android(print)
Day1 what is android(print)Day1 what is android(print)
Day1 what is android(print)Dongchul Shin
 
Android Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IAndroid Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IOpersys inc.
 
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 UniversityApplico
 
Build Mobile Application In Android
Build Mobile Application In AndroidBuild Mobile Application In Android
Build Mobile Application In Androiddnnddane
 
presentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdfpresentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdfimau6
 
Windows phone 7 application development
Windows phone 7 application developmentWindows phone 7 application development
Windows phone 7 application developmentMannu Malhotra
 
IOS vs Android presentation by Saikrishna
IOS vs Android presentation by SaikrishnaIOS vs Android presentation by Saikrishna
IOS vs Android presentation by SaikrishnaSaikrishna Tanguturu
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating systemSalma Begum
 
Fighting Fragmentation with Fragments
Fighting Fragmentation with FragmentsFighting Fragmentation with Fragments
Fighting Fragmentation with Fragmentsgrunicanada
 
Designing for Android - Anjan Shrestha
Designing for Android - Anjan ShresthaDesigning for Android - Anjan Shrestha
Designing for Android - Anjan ShresthaMobileNepal
 
Embedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC EuropeEmbedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC EuropeOpersys inc.
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android TipsKenichi Kambara
 
Supporting multi screen in android cn
Supporting multi screen in android cnSupporting multi screen in android cn
Supporting multi screen in android cnrffffffff007
 
Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013Opersys inc.
 
PRESENTATION ON ANDROID
PRESENTATION ON ANDROIDPRESENTATION ON ANDROID
PRESENTATION ON ANDROIDRajat Kumar
 

Semelhante a [Droidcon]Developing Apps for Android on 2.x/3.x/4.x (20)

Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids. Introduction to mobile programming with Androids.
Introduction to mobile programming with Androids.
 
Introduction To android
Introduction To androidIntroduction To android
Introduction To android
 
20130301 mobile os - the future (by empatika.com)
20130301 mobile os - the future (by empatika.com)20130301 mobile os - the future (by empatika.com)
20130301 mobile os - the future (by empatika.com)
 
Module 1
Module 1Module 1
Module 1
 
Day1 what is android(print)
Day1 what is android(print)Day1 what is android(print)
Day1 what is android(print)
 
Android Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part IAndroid Jumpstart ESC SV 2012 Part I
Android Jumpstart ESC SV 2012 Part I
 
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
 
Build Mobile Application In Android
Build Mobile Application In AndroidBuild Mobile Application In Android
Build Mobile Application In Android
 
presentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdfpresentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdf
 
Windows phone 7 application development
Windows phone 7 application developmentWindows phone 7 application development
Windows phone 7 application development
 
IOS vs Android presentation by Saikrishna
IOS vs Android presentation by SaikrishnaIOS vs Android presentation by Saikrishna
IOS vs Android presentation by Saikrishna
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating system
 
Fighting Fragmentation with Fragments
Fighting Fragmentation with FragmentsFighting Fragmentation with Fragments
Fighting Fragmentation with Fragments
 
Designing for Android - Anjan Shrestha
Designing for Android - Anjan ShresthaDesigning for Android - Anjan Shrestha
Designing for Android - Anjan Shrestha
 
Android nougat
Android nougatAndroid nougat
Android nougat
 
Embedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC EuropeEmbedded Android Workshop at ELC Europe
Embedded Android Workshop at ELC Europe
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips
 
Supporting multi screen in android cn
Supporting multi screen in android cnSupporting multi screen in android cn
Supporting multi screen in android cn
 
Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013Embedded Android Workshop / ELC 2013
Embedded Android Workshop / ELC 2013
 
PRESENTATION ON ANDROID
PRESENTATION ON ANDROIDPRESENTATION ON ANDROID
PRESENTATION ON ANDROID
 

Mais de Kenichi Kambara

Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)
Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)
Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)Kenichi Kambara
 
Hello Flutter”の次におさえたい Flutterのポイント その5
Hello Flutter”の次におさえたい Flutterのポイント その5Hello Flutter”の次におさえたい Flutterのポイント その5
Hello Flutter”の次におさえたい Flutterのポイント その5Kenichi Kambara
 
[ABC2018Spring]Flutterアプリ開発入門
[ABC2018Spring]Flutterアプリ開発入門[ABC2018Spring]Flutterアプリ開発入門
[ABC2018Spring]Flutterアプリ開発入門Kenichi Kambara
 
“Hello Flutter”の次におさえたい Flutterのポイント その4
“Hello Flutter”の次におさえたい Flutterのポイント その4“Hello Flutter”の次におさえたい Flutterのポイント その4
“Hello Flutter”の次におさえたい Flutterのポイント その4Kenichi Kambara
 
[Google I/O 2018 Highlights] Sandbox
[Google I/O 2018 Highlights] Sandbox[Google I/O 2018 Highlights] Sandbox
[Google I/O 2018 Highlights] SandboxKenichi Kambara
 
[Google I/O 2018 Highlights] Flutter / WearOS
[Google I/O 2018 Highlights] Flutter / WearOS[Google I/O 2018 Highlights] Flutter / WearOS
[Google I/O 2018 Highlights] Flutter / WearOSKenichi Kambara
 
"Hello Flutter"の次におさえたいFlutterのポイントその3
"Hello Flutter"の次におさえたいFlutterのポイントその3"Hello Flutter"の次におさえたいFlutterのポイントその3
"Hello Flutter"の次におさえたいFlutterのポイントその3Kenichi Kambara
 
Hello Flutterの次におさえたいFlutterのポイントその2
Hello Flutterの次におさえたいFlutterのポイントその2Hello Flutterの次におさえたいFlutterのポイントその2
Hello Flutterの次におさえたいFlutterのポイントその2Kenichi Kambara
 
I/Oへの期待+海外渡航持ち物Tips
I/Oへの期待+海外渡航持ち物TipsI/Oへの期待+海外渡航持ち物Tips
I/Oへの期待+海外渡航持ち物TipsKenichi Kambara
 
Hello Flutterの次におさえたいFlutterのポイント
Hello Flutterの次におさえたいFlutterのポイントHello Flutterの次におさえたいFlutterのポイント
Hello Flutterの次におさえたいFlutterのポイントKenichi Kambara
 
Developing Android Apps for Google Assistant
Developing Android Apps for Google AssistantDeveloping Android Apps for Google Assistant
Developing Android Apps for Google AssistantKenichi Kambara
 
Google Assistant対応アプリ開発3つのポイント
Google Assistant対応アプリ開発3つのポイントGoogle Assistant対応アプリ開発3つのポイント
Google Assistant対応アプリ開発3つのポイントKenichi Kambara
 
10分で作るGoogle Assistant対応アプリ
10分で作るGoogle Assistant対応アプリ10分で作るGoogle Assistant対応アプリ
10分で作るGoogle Assistant対応アプリKenichi Kambara
 
[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所
[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所
[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所Kenichi Kambara
 
Android O (Picture In Picture)入門+実装例
Android O (Picture In Picture)入門+実装例Android O (Picture In Picture)入門+実装例
Android O (Picture In Picture)入門+実装例Kenichi Kambara
 
AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例Kenichi Kambara
 
Publishing Android Wear 2.0 Apps
Publishing Android Wear 2.0 AppsPublishing Android Wear 2.0 Apps
Publishing Android Wear 2.0 AppsKenichi Kambara
 
Android Studio 2.3 New Features
Android Studio 2.3 New FeaturesAndroid Studio 2.3 New Features
Android Studio 2.3 New FeaturesKenichi Kambara
 
Android 7.0 Nougat マルチウィンドウ解説+α
Android 7.0 Nougat マルチウィンドウ解説+αAndroid 7.0 Nougat マルチウィンドウ解説+α
Android 7.0 Nougat マルチウィンドウ解説+αKenichi Kambara
 

Mais de Kenichi Kambara (20)

Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)
Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)
Hello Flutterの次におさえたい Flutterのポイント その6 (レイアウト編)
 
Hello Flutter”の次におさえたい Flutterのポイント その5
Hello Flutter”の次におさえたい Flutterのポイント その5Hello Flutter”の次におさえたい Flutterのポイント その5
Hello Flutter”の次におさえたい Flutterのポイント その5
 
[ABC2018Spring]Flutterアプリ開発入門
[ABC2018Spring]Flutterアプリ開発入門[ABC2018Spring]Flutterアプリ開発入門
[ABC2018Spring]Flutterアプリ開発入門
 
“Hello Flutter”の次におさえたい Flutterのポイント その4
“Hello Flutter”の次におさえたい Flutterのポイント その4“Hello Flutter”の次におさえたい Flutterのポイント その4
“Hello Flutter”の次におさえたい Flutterのポイント その4
 
[Google I/O 2018 Highlights] Sandbox
[Google I/O 2018 Highlights] Sandbox[Google I/O 2018 Highlights] Sandbox
[Google I/O 2018 Highlights] Sandbox
 
[Google I/O 2018 Highlights] Flutter / WearOS
[Google I/O 2018 Highlights] Flutter / WearOS[Google I/O 2018 Highlights] Flutter / WearOS
[Google I/O 2018 Highlights] Flutter / WearOS
 
"Hello Flutter"の次におさえたいFlutterのポイントその3
"Hello Flutter"の次におさえたいFlutterのポイントその3"Hello Flutter"の次におさえたいFlutterのポイントその3
"Hello Flutter"の次におさえたいFlutterのポイントその3
 
Hello Flutterの次におさえたいFlutterのポイントその2
Hello Flutterの次におさえたいFlutterのポイントその2Hello Flutterの次におさえたいFlutterのポイントその2
Hello Flutterの次におさえたいFlutterのポイントその2
 
I/Oへの期待+海外渡航持ち物Tips
I/Oへの期待+海外渡航持ち物TipsI/Oへの期待+海外渡航持ち物Tips
I/Oへの期待+海外渡航持ち物Tips
 
Hello Flutterの次におさえたいFlutterのポイント
Hello Flutterの次におさえたいFlutterのポイントHello Flutterの次におさえたいFlutterのポイント
Hello Flutterの次におさえたいFlutterのポイント
 
Developing Android Apps for Google Assistant
Developing Android Apps for Google AssistantDeveloping Android Apps for Google Assistant
Developing Android Apps for Google Assistant
 
Google Assistant対応アプリ開発3つのポイント
Google Assistant対応アプリ開発3つのポイントGoogle Assistant対応アプリ開発3つのポイント
Google Assistant対応アプリ開発3つのポイント
 
10分で作るGoogle Assistant対応アプリ
10分で作るGoogle Assistant対応アプリ10分で作るGoogle Assistant対応アプリ
10分で作るGoogle Assistant対応アプリ
 
[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所
[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所
[Kotlin勉強会] Hello Kotlinの次におさえたいKotlinの勘所
 
Android O (Picture In Picture)入門+実装例
Android O (Picture In Picture)入門+実装例Android O (Picture In Picture)入門+実装例
Android O (Picture In Picture)入門+実装例
 
AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例
 
Android O (Beta) Topics
Android O (Beta) TopicsAndroid O (Beta) Topics
Android O (Beta) Topics
 
Publishing Android Wear 2.0 Apps
Publishing Android Wear 2.0 AppsPublishing Android Wear 2.0 Apps
Publishing Android Wear 2.0 Apps
 
Android Studio 2.3 New Features
Android Studio 2.3 New FeaturesAndroid Studio 2.3 New Features
Android Studio 2.3 New Features
 
Android 7.0 Nougat マルチウィンドウ解説+α
Android 7.0 Nougat マルチウィンドウ解説+αAndroid 7.0 Nougat マルチウィンドウ解説+α
Android 7.0 Nougat マルチウィンドウ解説+α
 

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

  • 1. Droidcon London 2012 Developing Apps for Android on 2.x/3.x/4.x Kenichi Kambara (@korodroid) October 26, 2012
  • 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 2
  • 3. 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
  • 4. Agenda • Introduction • Background • Android Fundamentals • Application Development Tips 4
  • 5. My session topics Some tips on developing Apps for multi versions and multi devices. 2.x 3.x 4.x Handsets Tablets 5
  • 7. 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
  • 8. Use Case (1) Phone mode (Auto translating to receiver’s native language) English Japanese Hello! Talking Konnichiwa! Talking Paul Kenichi Thanks! Arigatou! 8
  • 9. Use Case (2) Talk mode (Auto translating on the spot) English Japanese 9
  • 10. App Demos (1.Phone mode) English Japanese Hello! Talking Konnichiwa! Talking Paul Kenichi Thanks! Arigatou! 10
  • 11. App Demos (2.Talk mode) 11
  • 12. App Screenshots on Android 2.x Portrait Landscape 12
  • 13. App Screenshots on Android 3.x Portrait Landscape 13
  • 14. App Screenshots on Android 4.x Portrait Landscape 14
  • 16. Current Android Devices Handsets Handsets (Almost all) & Tablets 2.x Tablets 4.x (All) 3.x 16
  • 17. Platform Versions? This data by Google on October 1, 2012 17
  • 18. 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
  • 19. Screen Sizes & Densities? xhdpi Normal Small ldpi Xlarge hdpi Large mdpi This data by Google on October 1, 2012 19
  • 20. Screen Sizes & Densities? This data by Google on October 1, 2012 In my App: Main Target: (normal,large,xlarge)x(mdpi,hdpi,xhdpi) 20
  • 22. Fragment? Handset Tablet Activity A Activity B Activity A 22
  • 23. Fragment? Handset Tablet Fragment X Fragment Y Fragment X Fragment Y Activity A Activity B Activity A 23
  • 24. Menu? Options Menu Action Bar (2.x) (3.0+) 24
  • 26. 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
  • 27. 1.  Designing User Interface [Some Approaches] 27
  • 28. [UI]1 st Approach Using layout-small/normal/large/xlarge Screen 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
  • 29. [UI]Introduction of 2nd Approach Using “dp(Density-Independent pixel)” Width sizes Devices 320dp Typical Handsets 600dp 7” tablet 720dp 10” tablet 29
  • 30. [UI]2 nd Approach e.g.)Supporting Handsets & 2 Tablets Handsets 7’’ Tablet 10’’ Tablet l  res/layout/main.xml l  res/layout-sw600dp/main.xml l  res/layout-sw720dp/main.xml 30
  • 31. [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
  • 32. [UI]2 nd Approach Using sw<N>dp,w<N>dp,h<N>dp 400 dp 960 dp (a)layout-sw600dp false (b)layout-w720dp true (c)layout-h480dp false 32
  • 33. [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
  • 34. [UI]3 rd Approach Combination of 1st and 2nd l  res/layout-sw600dp/main.xml <- 3.2+ tablets l  res/layout-xlarge/main.xml <- 3.0/3.1 tablets l  res/layout/main.xml <- The others (Handsets) l  Supports Android 1.6 l  Supports many devices (compared to 1st or 2nd) l  Any Problem? 34
  • 35. [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 tablets l  res/layout/main.xml <- The others (Handsets) •  Needs to put the same file for tablets. (Maintenance headache…) 35
  • 36. [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
  • 37. Which is the Better Approach? 37
  • 38. [UI]4 th Approach Based on 3rd , plus some tips •  Put minimum requirement for layouts 38
  • 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> 39
  • 40. [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
  • 42. [API]Fragment Using Support Library? 2.x 3.x 4.x Without Support Library With Support Library 42
  • 43. [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
  • 44. [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
  • 45. [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
  • 46. [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
  • 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 4.x 2.x 3.x 47
  • 48. [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
  • 49. [API]Multi-Versioning Development?, Management?, APK Size? Single APK Multiple APK 49
  • 50. [API]Multi-Versioning Single APK In my App: Developed by Single APK 50
  • 51. [API]Multi-Versioning How to use the newest API on Single APK Reflection Well known approach Lazy loading One of Design Patterns 51
  • 52. [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
  • 53. [API]Multi-Versioning Code Examples of Lazy loading 1 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
  • 54. [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
  • 55. 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
  • 56. 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
  • 57. 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