SlideShare a Scribd company logo
www.immobilienscout24.de

Best Practices to develop for
different Android Device Classifications

Droidcon | Turin| 07.02.2014 | Hasan Hosgel
About me

+HasanHosgel
Twitter: @alosdev
Github:
alosdev
Slideshare: hosgel
CO-Organizer @ GDG
Android in Berlin
& community events
developer @
ImmobilienScout24

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
About ImmobilienScout24

Germany’s largest real
estate listing company.
> 10 Mio. Monthly unique
users
> 1.5 Mio. real estates
> 300 Mio. detail views
> 1500 Servers
~ 7.5 Mio. App downloads
> 3 Mio. Android
> 50% mobile traffic

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Fragmentation

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Fragmentation

> 5000 Android Devices

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Here comes The Nightmare

Image source:
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
http://www.flickr.com/photos/boogeyman13/4553188509/
Here comes The Nightmare

For developers
Image source:
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
http://www.flickr.com/photos/boogeyman13/4553188509/
Let’s build the fundament

Image source:
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
http://www.flickr.com/photos/hertenberger/1434191066/
Device Classification

Images sources:
https://play.google.com/store/devices

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Device Classification

Images sources:
https://play.google.com/store/devices
http://www.htc.com/de/

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Device Classification

Images sources:
http://www.sony.de/hub/google-tv

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Device Classification

Images Sources
https://developer.ford.com/

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Open Automotive Alliance

Starting 2014 several companies plan to bring
Android platform to the cars.
• Audi
• GM
• Google
• Honda
• Hyundai
• Nvidia
http://www.openautoalliance.net/

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Wearables

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Glass

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Hard Work Ahead

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel

Source: http://www.flickr.com/photos/16210667@N02/9172895225
Resource Folders

You can use several qualifiers in the resource
folders name for serving the best matching
resource.

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Qualifiers

● Language (-en)
● Language & Region (-en-rUS)
● Smallest Width (–sw600dp)
● Screensize (-small, -normal, -large)
● Screen Orientation (-port, -land)
● Screen Pixel Densitiy (-hdpi, -xhdpi, -xxhdpi)
● Platform Version (-v11, -v13)

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Best Matching Resources Win

1.res/values/strings.xml
2.res/values-en-rUS/strings.xml
3.res/values-large/strings.xml
4.res/values-sw600dp/strings.xml

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Best Matching Resources Win

1.res/values/strings.xml
2.res/values-en-rUS/strings.xml
3.res/values-large/strings.xml
4.res/values-sw600dp/strings.xml
The order of the qualifiers in the previous slides gives
the ranking, if two resources have the same matching
number of qualifiers.

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Images Resources

• Use the different qualifiers for the screen pixel
density (mdpi, hdpi, etc.)
• If you are forced to use text on images use
language and region (en, es-rUS, en-rUS, etc.)
• Better approach is to use 9-patch drawables,
which stretches automatically depending on the
content inside.
• You must provide different launcher icons for
Froyo, Honeycomb and above? Use the platform
version. (v4, v11, v14)

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Classifications for Layouts

Platform version at least v13 (Honeycomb
MR2)

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Classifications for Layouts

Platform version at least v13 (Honeycomb
MR2)
project-folder/res/

layout/

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Classifications for Layouts

Platform version at least v13 (Honeycomb
MR2)
project-folder/res/

layout/

 small phones

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Classifications for Layouts

Platform version at least v13 (Honeycomb
MR2)
project-folder/res/

layout/

 small phones

layout-sw320dp/

 other phones

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Classifications for Layouts

Platform version at least v13 (Honeycomb
MR2)
project-folder/res/

layout/

 small phones

layout-sw320dp/

 other phones

layout-sw600dp/

 tablets 7”

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Classifications for Layouts

Platform version at least v13 (Honeycomb
MR2)
project-folder/res/

layout/

 small phones

layout-sw320dp/

 other phones

layout-sw600dp/

 tablets 7”

layout-sw720dp/

 tablets 10”

* You should also use the orientation qualifier

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Platform version at lower v11
project-folder/res/
layout/

 phones

layout-sw320dp/

 other phones

layout-sw600dp/

 tablets 7”

layout-sw720dp/

 tablets 10”

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Platform version at lower v11
project-folder/res/
layout/

 phones

layout-v11/

 tablets 10”

layout-sw320dp/

 other phones

layout-sw600dp/

 tablets 7”

layout-sw720dp/

 tablets 10”

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Platform version at lower v11
project-folder/res/
layout/

 phones

layout-v11/

 tablets 10”

layout-v13/

 small phones

layout-sw320dp/

 other phones

layout-sw600dp/

 tablets 7”

layout-sw720dp/

 tablets 10”

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Hint

The smallest width qualifier gets automatically
platform version ”-v13” through the packager,
for avoiding problems with the number of
matching qualifiers.

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Howto Classify In Code

• Read configuration from the device

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Howto Classify In Code

• Read configuration from the device
• Smarter approach is to use boolean resources

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
project-folder/res/values/layouts.xml
<resources>

</resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
project-folder/res/values/layouts.xml
<resources>
<bool

>

</bool>

</resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
project-folder/res/values/layouts.xml
<resources>
<bool name="is_phone_small">

</bool>

</resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
project-folder/res/values/layouts.xml
<resources>
<bool name="is_phone_small">true</bool>

</resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
project-folder/res/values/layouts.xml
<resources>
<bool name="is_phone_small">true</bool>
<bool name="is_phone_other">false</bool>

<bool name="is_tablet_7">false</bool>
<bool name="is_tablet_10">false</bool>
</resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
project-folder/res/values/layouts.xml
<resources>
<bool name="is_phone_small">true</bool>
<bool name="is_phone_other">false</bool>

<bool name="is_tablet_7">false</bool>
<bool name="is_tablet_10">false</bool>
</resources>
Usage in code:
getResources().getBoolean(R.bool.is_phone_small)
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Current Layout File Structure

project-folder/res/
layout/main.xml
layout-v11/main.xml
layout-v13/main.xml
layout-sw320dp/main.xml
layout-sw600dp/main.xml
layout-sw720dp/main.xml

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Current Layout File Structure

project-folder/res/
layout/main.xml
layout-v11/main.xml
layout-v13/main.xml
layout-sw320dp/main.xml
layout-sw600dp/main.xml
layout-sw720dp/main.xml
Fixing one bug in the 10“ layout has to be done in two files.

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Current Layout File Structure

project-folder/res/
layout/main.xml
layout-v11/main.xml
layout-v13/main.xml
layout-sw320dp/main.xml
layout-sw600dp/main.xml
layout-sw720dp/main.xml
Fixing one bug in the 10“ layout has to be done in two files.
 error prone

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Resource Alias

Put your layout files in the default folder.
project-folder/res/
layout/main_phone_small.xml

layout/main_phone_other.xml
layout/main_tablet_7.xml
layout/main_tablet_10.xml

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Resource Alias

2. Create an item with the needed
classification in the previously defined values
folder.

project-folder/res/valuessw720dp/layouts.xml
<resources>

</resources>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Resource Alias

2. Create an item with the needed
classification in the previously defined values
folder.

project-folder/res/valuessw720dp/layouts.xml
<resources>

<item

>
</item>

</resources>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Resource Alias

2. Create an item with the needed
classification in the previously defined values
folder.

project-folder/res/valuessw720dp/layouts.xml
<resources>

<item name="main"

>
</item>

</resources>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Resource Alias

2. Create an item with the needed
classification in the previously defined values
folder.

project-folder/res/valuessw720dp/layouts.xml
<resources>

<item name="main" type="layout">
</item>
</resources>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Resource Alias

2. Create an item with the needed
classification in the previously defined values
folder.

project-folder/res/valuessw720dp/layouts.xml
<resources>

<item name="main" type="layout">
@layout/main_tablet_10.xml</item>
</resources>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Sample Screen

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Sample Screen

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Sample Screen

Use <includes>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Usage Includes

<LinearLayout … >
…
…
</LinearLayout>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Usage Includes

<LinearLayout … >
…
<include
…
</LinearLayout>

/>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Usage Includes

<LinearLayout … >
…
<include layout="@layout/footer"/>
…
</LinearLayout>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Sample Screen

Use <includes>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Sample Screen

Use <includes>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Sample Screen

Create custom view

Use <includes>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom View

public class CustomView extends LinearLayout {
…
public CustomView(Context context, AttributeSet attrs)
{
…
addView(createTextView(context, "label"), lp);
addView(createTextView(context, "desc"), lp);
if(getResources().getBoolean(R.bool.is_phone)){
setOrientation(VERTICAL);
} else {
setOrientation(HORIZONTAL);
}
}
…
}
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Usage CustomView in layout file

<LinearLayout … >
…

…
</LinearLayout>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Usage CustomView in layout file

<LinearLayout … >
…
<de.alosdev.CustomView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
…
</LinearLayout>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Sample Screen

Create custom view

Use <includes>
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom XML Attribute
<resources>
<declare-styleable

>

</declare-styleable>
<resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom XML Attribute
<resources>
<declare-styleable name=”CustomView">

</declare-styleable>
<resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom XML Attribute
<resources>
<declare-styleable name=”CustomView">
<attr

</declare-styleable>
<resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel

/>
Custom XML Attribute
<resources>
<declare-styleable name=”CustomView">
<attr name="label"

</declare-styleable>
<resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel

/>
Custom XML Attribute
<resources>
<declare-styleable name=”CustomView">
<attr name="label" format="reference|string"/>

</declare-styleable>
<resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom XML Attribute
<resources>
<declare-styleable name=”CustomView">
<attr name="label" format="reference|string"/>
<attr name="value" format="reference|string"/>
<attr name="orientation" format="enum">
<enum name="horizontal" value="0"/>
<enum name="vertical" value="1"/>
</attr>
</declare-styleable>
<resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Usage in layout resource

1. Add to root XML node
xmlns:app="http://schemas.android.com/apk/resauto"
2. Usage in custom view
<de.alosdev.CustomView
android:id="@+id/customView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:label="label 1"
app:orientation="vertical"
app:value="value 1" />

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Usage in code

public class CustomView extends LinearLayout {
static final int[] ORIENTATION = new int[] { HORIZONTAL, VERTICAL };
public CustomView(Context context, AttributeSet
attrs) {
super(context, attrs);
…
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.CustomView);
try {
setOrientation(ORIENTATION[
a.getInt(R.styleable.CustomView_orientation, 0)]);
} finally {
a.recycle();
}
}
…
}

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom XML Attribute

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom XML Attribute

If custom view has much more
business logic and need lifecycles
 Create a Fragment

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Code

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Best Practices

● You have already an application
Remove orientation fixation and
suppressing of orientation change from
manifest to avoid long bug analyzing.

● You start from the scratch

Focus on main classification for faster time
to market

But create an overall concept for better
modularization
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Best Practices

● If you support both orientations, save the
instance state while orientation changes for
more responsiveness
Especially for states, that need a long
computation for creation.
Make the state object Parcelable for faster
write & read and also to have a smaller

memory footprint

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Developer Hints

● You can start an activity for result from a
fragment, so the response can be handled in
the fragment.

● If you want to register a special service on
every onCreate method of an activity give the
ActivityLivecycleCallbacks a try. You can
register them in the onCreate method of the

application. (minSDK -v14)

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
● If you get a BadParcelableException with
the cause ClassNotFound-Exception, the
source can be a NullPointerException
during the read or write of the Parcelable.

Exceptions are hidden during the parcel
process.

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
If you want to use “match_parent” or
“wrap_content” in a dimension alias, you should use
“-1dp” or “-2dp”
project-folder/res/values/dimen.xml

<resources>
<dimen name="my_dimen>@dimen/match_parent</dimen>
<dimen name="match_parent">-1dp</dimen>
<dimen name="wrap_content">-2dp</dimen>

</resources>
project-folder/res/values-sw600dp/layout.xml
<resources>

<dimen name="my_dimen>300dp</dimen>
</resources>

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Listener Hell

If you have to many listeners or you think the
programming model is old school like the “goto
statements”. Give message/ event/ service
bus a try. For Android:
Otto from Square
EventBus from greenrobot

See also: Callbacks as our Generations' Go To
Statement
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Custom Theme & Style
Android Ui Utils

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
ActionBar Style Generator

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Holo Color Generator

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Mission Accomplished ?

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
http://www.flickr.com/photos/ianaberle/5729561934/
Mission Accomplished

Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
http://www.flickr.com/photos/ianaberle/5729561934/
Q&A

Page 85
Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
Source: http://www.flickr.com/photos/21496790@N06/5065834411/
www.immobilienscout24.de

Thanks for your attention!
Contact:
+HasanHosgel
Twitter: @alosdev
Github: alosdev

Best Practices to develop for different Android Device Classifications
https://github.com/alosdev/multidevice-nightmare-demo
http://www.slideshare.net/hosgel/droidcon-it-2014-best-practices-to-develop-fordifferent-android-device-classifications

More Related Content

Similar to Droidcon it 2014 best practices to develop for different android device classifications

Droidcon 2013 multidevice nightmare
Droidcon 2013 multidevice nightmareDroidcon 2013 multidevice nightmare
Droidcon 2013 multidevice nightmareDroidcon Berlin
 
Android Developer Days 2013 - MultiDevice Nightmare
Android Developer Days 2013 - MultiDevice NightmareAndroid Developer Days 2013 - MultiDevice Nightmare
Android Developer Days 2013 - MultiDevice NightmareHasan Hosgel
 
Desenvolvimento de Aplicativo Multiplataforma com Intel® XDK
Desenvolvimento de Aplicativo Multiplataforma com  Intel® XDKDesenvolvimento de Aplicativo Multiplataforma com  Intel® XDK
Desenvolvimento de Aplicativo Multiplataforma com Intel® XDKEvandro Paes
 
Android Scripting
Android ScriptingAndroid Scripting
Android ScriptingJuan Gomez
 
Experience The Best Android Programming Training Here | LW India
Experience The Best Android Programming Training Here | LW IndiaExperience The Best Android Programming Training Here | LW India
Experience The Best Android Programming Training Here | LW IndiaVishakhaTalmale
 
Why The Future of Flutter Will Be Your Next Big Obsession.pdf
Why The Future of Flutter Will Be Your Next Big Obsession.pdfWhy The Future of Flutter Will Be Your Next Big Obsession.pdf
Why The Future of Flutter Will Be Your Next Big Obsession.pdfTechugo
 
Android Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTAndroid Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTinovex GmbH
 
Whitepaper - Native App or HTML5
Whitepaper - Native App or HTML5Whitepaper - Native App or HTML5
Whitepaper - Native App or HTML5Dan Vitoriano
 
Wp7 guide for android developers
Wp7 guide for android developersWp7 guide for android developers
Wp7 guide for android developersacebisli
 
Extending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptExtending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptRoy Clarkson
 
Hoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxHoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxMattMarino13
 
Why is flutter mobile app development mostly recommended for your business
Why is flutter mobile app development mostly recommended for your businessWhy is flutter mobile app development mostly recommended for your business
Why is flutter mobile app development mostly recommended for your businessFullestop
 
Seminar on android app development
Seminar on android app developmentSeminar on android app development
Seminar on android app developmentAbhishekKumar4779
 
Android App Development - 01 Introduction
Android App Development - 01 IntroductionAndroid App Development - 01 Introduction
Android App Development - 01 IntroductionDiego Grancini
 
Why is flutter considered the best cross platform framework
Why is flutter considered the best cross platform frameworkWhy is flutter considered the best cross platform framework
Why is flutter considered the best cross platform frameworkPixel Crayons
 
Quickly Develop Android Applications for Multiple Languages
Quickly Develop Android Applications for Multiple LanguagesQuickly Develop Android Applications for Multiple Languages
Quickly Develop Android Applications for Multiple LanguagesMotorola Mobility - MOTODEV
 
Android Localization
Android LocalizationAndroid Localization
Android LocalizationKaran Geddam
 

Similar to Droidcon it 2014 best practices to develop for different android device classifications (20)

Droidcon 2013 multidevice nightmare
Droidcon 2013 multidevice nightmareDroidcon 2013 multidevice nightmare
Droidcon 2013 multidevice nightmare
 
Android Developer Days 2013 - MultiDevice Nightmare
Android Developer Days 2013 - MultiDevice NightmareAndroid Developer Days 2013 - MultiDevice Nightmare
Android Developer Days 2013 - MultiDevice Nightmare
 
Desenvolvimento de Aplicativo Multiplataforma com Intel® XDK
Desenvolvimento de Aplicativo Multiplataforma com  Intel® XDKDesenvolvimento de Aplicativo Multiplataforma com  Intel® XDK
Desenvolvimento de Aplicativo Multiplataforma com Intel® XDK
 
Android Scripting
Android ScriptingAndroid Scripting
Android Scripting
 
Experience The Best Android Programming Training Here | LW India
Experience The Best Android Programming Training Here | LW IndiaExperience The Best Android Programming Training Here | LW India
Experience The Best Android Programming Training Here | LW India
 
Why The Future of Flutter Will Be Your Next Big Obsession.pdf
Why The Future of Flutter Will Be Your Next Big Obsession.pdfWhy The Future of Flutter Will Be Your Next Big Obsession.pdf
Why The Future of Flutter Will Be Your Next Big Obsession.pdf
 
Android Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTAndroid Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoT
 
Whitepaper - Native App or HTML5
Whitepaper - Native App or HTML5Whitepaper - Native App or HTML5
Whitepaper - Native App or HTML5
 
Wp7 guide for android developers
Wp7 guide for android developersWp7 guide for android developers
Wp7 guide for android developers
 
Windows Phone 7 Guide for Android Application Developers
Windows Phone 7 Guide for Android Application DevelopersWindows Phone 7 Guide for Android Application Developers
Windows Phone 7 Guide for Android Application Developers
 
Flutter
FlutterFlutter
Flutter
 
Extending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScriptExtending Spring MVC with Spring Mobile and JavaScript
Extending Spring MVC with Spring Mobile and JavaScript
 
divide and qonquer
divide and qonquerdivide and qonquer
divide and qonquer
 
Hoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptxHoisington_Android_4e_PPT_CH01.pptx
Hoisington_Android_4e_PPT_CH01.pptx
 
Why is flutter mobile app development mostly recommended for your business
Why is flutter mobile app development mostly recommended for your businessWhy is flutter mobile app development mostly recommended for your business
Why is flutter mobile app development mostly recommended for your business
 
Seminar on android app development
Seminar on android app developmentSeminar on android app development
Seminar on android app development
 
Android App Development - 01 Introduction
Android App Development - 01 IntroductionAndroid App Development - 01 Introduction
Android App Development - 01 Introduction
 
Why is flutter considered the best cross platform framework
Why is flutter considered the best cross platform frameworkWhy is flutter considered the best cross platform framework
Why is flutter considered the best cross platform framework
 
Quickly Develop Android Applications for Multiple Languages
Quickly Develop Android Applications for Multiple LanguagesQuickly Develop Android Applications for Multiple Languages
Quickly Develop Android Applications for Multiple Languages
 
Android Localization
Android LocalizationAndroid Localization
Android Localization
 

More from Hasan Hosgel

MTC 2013 Berlin - Best Practices for Multi Devices
MTC 2013 Berlin - Best Practices for Multi DevicesMTC 2013 Berlin - Best Practices for Multi Devices
MTC 2013 Berlin - Best Practices for Multi DevicesHasan Hosgel
 
Android bootcamp 2013 Lists & Adapter
Android bootcamp 2013 Lists & AdapterAndroid bootcamp 2013 Lists & Adapter
Android bootcamp 2013 Lists & AdapterHasan Hosgel
 
Customer's Choice @ Moosecon 2013
Customer's Choice @ Moosecon 2013Customer's Choice @ Moosecon 2013
Customer's Choice @ Moosecon 2013Hasan Hosgel
 
Customer&rsquo;s Choice @ GDG Android Berlin on January meetup
Customer&rsquo;s Choice @ GDG Android Berlin on January meetupCustomer&rsquo;s Choice @ GDG Android Berlin on January meetup
Customer&rsquo;s Choice @ GDG Android Berlin on January meetupHasan Hosgel
 
Continuously Break The Android
Continuously Break The AndroidContinuously Break The Android
Continuously Break The AndroidHasan Hosgel
 
Coexisting of Android & Robots
Coexisting of Android & RobotsCoexisting of Android & Robots
Coexisting of Android & RobotsHasan Hosgel
 
Mobile Development across Different Platforms @ Immobilienscout24
Mobile Development across Different Platforms @ Immobilienscout24Mobile Development across Different Platforms @ Immobilienscout24
Mobile Development across Different Platforms @ Immobilienscout24Hasan Hosgel
 

More from Hasan Hosgel (7)

MTC 2013 Berlin - Best Practices for Multi Devices
MTC 2013 Berlin - Best Practices for Multi DevicesMTC 2013 Berlin - Best Practices for Multi Devices
MTC 2013 Berlin - Best Practices for Multi Devices
 
Android bootcamp 2013 Lists & Adapter
Android bootcamp 2013 Lists & AdapterAndroid bootcamp 2013 Lists & Adapter
Android bootcamp 2013 Lists & Adapter
 
Customer's Choice @ Moosecon 2013
Customer's Choice @ Moosecon 2013Customer's Choice @ Moosecon 2013
Customer's Choice @ Moosecon 2013
 
Customer&rsquo;s Choice @ GDG Android Berlin on January meetup
Customer&rsquo;s Choice @ GDG Android Berlin on January meetupCustomer&rsquo;s Choice @ GDG Android Berlin on January meetup
Customer&rsquo;s Choice @ GDG Android Berlin on January meetup
 
Continuously Break The Android
Continuously Break The AndroidContinuously Break The Android
Continuously Break The Android
 
Coexisting of Android & Robots
Coexisting of Android & RobotsCoexisting of Android & Robots
Coexisting of Android & Robots
 
Mobile Development across Different Platforms @ Immobilienscout24
Mobile Development across Different Platforms @ Immobilienscout24Mobile Development across Different Platforms @ Immobilienscout24
Mobile Development across Different Platforms @ Immobilienscout24
 

Recently uploaded

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»QADay
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsVlad Stirbu
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 

Recently uploaded (20)

Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Ransomware Mallox [EN].pdf
Ransomware         Mallox       [EN].pdfRansomware         Mallox       [EN].pdf
Ransomware Mallox [EN].pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»НАДІЯ ФЕДЮШКО БАЦ  «Професійне зростання QA спеціаліста»
НАДІЯ ФЕДЮШКО БАЦ «Професійне зростання QA спеціаліста»
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 

Droidcon it 2014 best practices to develop for different android device classifications

  • 1. www.immobilienscout24.de Best Practices to develop for different Android Device Classifications Droidcon | Turin| 07.02.2014 | Hasan Hosgel
  • 2. About me +HasanHosgel Twitter: @alosdev Github: alosdev Slideshare: hosgel CO-Organizer @ GDG Android in Berlin & community events developer @ ImmobilienScout24 Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 3. About ImmobilienScout24 Germany’s largest real estate listing company. > 10 Mio. Monthly unique users > 1.5 Mio. real estates > 300 Mio. detail views > 1500 Servers ~ 7.5 Mio. App downloads > 3 Mio. Android > 50% mobile traffic Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 4. Fragmentation Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 5. Fragmentation > 5000 Android Devices Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 6. Here comes The Nightmare Image source: Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel http://www.flickr.com/photos/boogeyman13/4553188509/
  • 7. Here comes The Nightmare For developers Image source: Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel http://www.flickr.com/photos/boogeyman13/4553188509/
  • 8. Let’s build the fundament Image source: Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel http://www.flickr.com/photos/hertenberger/1434191066/
  • 9. Device Classification Images sources: https://play.google.com/store/devices Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 10. Device Classification Images sources: https://play.google.com/store/devices http://www.htc.com/de/ Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 11. Device Classification Images sources: http://www.sony.de/hub/google-tv Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 12. Device Classification Images Sources https://developer.ford.com/ Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 13. Open Automotive Alliance Starting 2014 several companies plan to bring Android platform to the cars. • Audi • GM • Google • Honda • Hyundai • Nvidia http://www.openautoalliance.net/ Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 14. Wearables Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 15. Glass Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 16. Hard Work Ahead Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel Source: http://www.flickr.com/photos/16210667@N02/9172895225
  • 17. Resource Folders You can use several qualifiers in the resource folders name for serving the best matching resource. Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 18. Qualifiers ● Language (-en) ● Language & Region (-en-rUS) ● Smallest Width (–sw600dp) ● Screensize (-small, -normal, -large) ● Screen Orientation (-port, -land) ● Screen Pixel Densitiy (-hdpi, -xhdpi, -xxhdpi) ● Platform Version (-v11, -v13) Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 19. Best Matching Resources Win 1.res/values/strings.xml 2.res/values-en-rUS/strings.xml 3.res/values-large/strings.xml 4.res/values-sw600dp/strings.xml Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 20. Best Matching Resources Win 1.res/values/strings.xml 2.res/values-en-rUS/strings.xml 3.res/values-large/strings.xml 4.res/values-sw600dp/strings.xml The order of the qualifiers in the previous slides gives the ranking, if two resources have the same matching number of qualifiers. Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 21. Images Resources • Use the different qualifiers for the screen pixel density (mdpi, hdpi, etc.) • If you are forced to use text on images use language and region (en, es-rUS, en-rUS, etc.) • Better approach is to use 9-patch drawables, which stretches automatically depending on the content inside. • You must provide different launcher icons for Froyo, Honeycomb and above? Use the platform version. (v4, v11, v14) Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 22. Classifications for Layouts Platform version at least v13 (Honeycomb MR2) Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 23. Classifications for Layouts Platform version at least v13 (Honeycomb MR2) project-folder/res/ layout/ Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 24. Classifications for Layouts Platform version at least v13 (Honeycomb MR2) project-folder/res/ layout/  small phones Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 25. Classifications for Layouts Platform version at least v13 (Honeycomb MR2) project-folder/res/ layout/  small phones layout-sw320dp/  other phones Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 26. Classifications for Layouts Platform version at least v13 (Honeycomb MR2) project-folder/res/ layout/  small phones layout-sw320dp/  other phones layout-sw600dp/  tablets 7” Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 27. Classifications for Layouts Platform version at least v13 (Honeycomb MR2) project-folder/res/ layout/  small phones layout-sw320dp/  other phones layout-sw600dp/  tablets 7” layout-sw720dp/  tablets 10” * You should also use the orientation qualifier Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 28. Platform version at lower v11 project-folder/res/ layout/  phones layout-sw320dp/  other phones layout-sw600dp/  tablets 7” layout-sw720dp/  tablets 10” Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 29. Platform version at lower v11 project-folder/res/ layout/  phones layout-v11/  tablets 10” layout-sw320dp/  other phones layout-sw600dp/  tablets 7” layout-sw720dp/  tablets 10” Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 30. Platform version at lower v11 project-folder/res/ layout/  phones layout-v11/  tablets 10” layout-v13/  small phones layout-sw320dp/  other phones layout-sw600dp/  tablets 7” layout-sw720dp/  tablets 10” Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 31. Hint The smallest width qualifier gets automatically platform version ”-v13” through the packager, for avoiding problems with the number of matching qualifiers. Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 32. Howto Classify In Code • Read configuration from the device Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 33. Howto Classify In Code • Read configuration from the device • Smarter approach is to use boolean resources Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 34. project-folder/res/values/layouts.xml <resources> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 35. project-folder/res/values/layouts.xml <resources> <bool > </bool> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 38. project-folder/res/values/layouts.xml <resources> <bool name="is_phone_small">true</bool> <bool name="is_phone_other">false</bool> <bool name="is_tablet_7">false</bool> <bool name="is_tablet_10">false</bool> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 39. project-folder/res/values/layouts.xml <resources> <bool name="is_phone_small">true</bool> <bool name="is_phone_other">false</bool> <bool name="is_tablet_7">false</bool> <bool name="is_tablet_10">false</bool> </resources> Usage in code: getResources().getBoolean(R.bool.is_phone_small) Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 40. Current Layout File Structure project-folder/res/ layout/main.xml layout-v11/main.xml layout-v13/main.xml layout-sw320dp/main.xml layout-sw600dp/main.xml layout-sw720dp/main.xml Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 41. Current Layout File Structure project-folder/res/ layout/main.xml layout-v11/main.xml layout-v13/main.xml layout-sw320dp/main.xml layout-sw600dp/main.xml layout-sw720dp/main.xml Fixing one bug in the 10“ layout has to be done in two files. Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 42. Current Layout File Structure project-folder/res/ layout/main.xml layout-v11/main.xml layout-v13/main.xml layout-sw320dp/main.xml layout-sw600dp/main.xml layout-sw720dp/main.xml Fixing one bug in the 10“ layout has to be done in two files.  error prone Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 43. Resource Alias Put your layout files in the default folder. project-folder/res/ layout/main_phone_small.xml layout/main_phone_other.xml layout/main_tablet_7.xml layout/main_tablet_10.xml Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 44. Resource Alias 2. Create an item with the needed classification in the previously defined values folder. project-folder/res/valuessw720dp/layouts.xml <resources> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 45. Resource Alias 2. Create an item with the needed classification in the previously defined values folder. project-folder/res/valuessw720dp/layouts.xml <resources> <item > </item> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 46. Resource Alias 2. Create an item with the needed classification in the previously defined values folder. project-folder/res/valuessw720dp/layouts.xml <resources> <item name="main" > </item> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 47. Resource Alias 2. Create an item with the needed classification in the previously defined values folder. project-folder/res/valuessw720dp/layouts.xml <resources> <item name="main" type="layout"> </item> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 48. Resource Alias 2. Create an item with the needed classification in the previously defined values folder. project-folder/res/valuessw720dp/layouts.xml <resources> <item name="main" type="layout"> @layout/main_tablet_10.xml</item> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 49. Sample Screen Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 50. Sample Screen Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 51. Sample Screen Use <includes> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 52. Usage Includes <LinearLayout … > … … </LinearLayout> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 53. Usage Includes <LinearLayout … > … <include … </LinearLayout> /> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 54. Usage Includes <LinearLayout … > … <include layout="@layout/footer"/> … </LinearLayout> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 55. Sample Screen Use <includes> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 56. Sample Screen Use <includes> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 57. Sample Screen Create custom view Use <includes> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 58. Custom View public class CustomView extends LinearLayout { … public CustomView(Context context, AttributeSet attrs) { … addView(createTextView(context, "label"), lp); addView(createTextView(context, "desc"), lp); if(getResources().getBoolean(R.bool.is_phone)){ setOrientation(VERTICAL); } else { setOrientation(HORIZONTAL); } } … } Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 59. Usage CustomView in layout file <LinearLayout … > … … </LinearLayout> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 60. Usage CustomView in layout file <LinearLayout … > … <de.alosdev.CustomView android:layout_width="wrap_content" android:layout_height="wrap_content"/> … </LinearLayout> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 61. Sample Screen Create custom view Use <includes> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 62. Custom XML Attribute <resources> <declare-styleable > </declare-styleable> <resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 63. Custom XML Attribute <resources> <declare-styleable name=”CustomView"> </declare-styleable> <resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 64. Custom XML Attribute <resources> <declare-styleable name=”CustomView"> <attr </declare-styleable> <resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel />
  • 65. Custom XML Attribute <resources> <declare-styleable name=”CustomView"> <attr name="label" </declare-styleable> <resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel />
  • 66. Custom XML Attribute <resources> <declare-styleable name=”CustomView"> <attr name="label" format="reference|string"/> </declare-styleable> <resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 67. Custom XML Attribute <resources> <declare-styleable name=”CustomView"> <attr name="label" format="reference|string"/> <attr name="value" format="reference|string"/> <attr name="orientation" format="enum"> <enum name="horizontal" value="0"/> <enum name="vertical" value="1"/> </attr> </declare-styleable> <resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 68. Usage in layout resource 1. Add to root XML node xmlns:app="http://schemas.android.com/apk/resauto" 2. Usage in custom view <de.alosdev.CustomView android:id="@+id/customView" android:layout_width="wrap_content" android:layout_height="wrap_content" app:label="label 1" app:orientation="vertical" app:value="value 1" /> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 69. Usage in code public class CustomView extends LinearLayout { static final int[] ORIENTATION = new int[] { HORIZONTAL, VERTICAL }; public CustomView(Context context, AttributeSet attrs) { super(context, attrs); … TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomView); try { setOrientation(ORIENTATION[ a.getInt(R.styleable.CustomView_orientation, 0)]); } finally { a.recycle(); } } … } Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 70. Custom XML Attribute Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 71. Custom XML Attribute If custom view has much more business logic and need lifecycles  Create a Fragment Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 72. Code Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 73. Best Practices ● You have already an application Remove orientation fixation and suppressing of orientation change from manifest to avoid long bug analyzing. ● You start from the scratch Focus on main classification for faster time to market But create an overall concept for better modularization Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 74. Best Practices ● If you support both orientations, save the instance state while orientation changes for more responsiveness Especially for states, that need a long computation for creation. Make the state object Parcelable for faster write & read and also to have a smaller memory footprint Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 75. Developer Hints ● You can start an activity for result from a fragment, so the response can be handled in the fragment. ● If you want to register a special service on every onCreate method of an activity give the ActivityLivecycleCallbacks a try. You can register them in the onCreate method of the application. (minSDK -v14) Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 76. ● If you get a BadParcelableException with the cause ClassNotFound-Exception, the source can be a NullPointerException during the read or write of the Parcelable. Exceptions are hidden during the parcel process. Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 77. If you want to use “match_parent” or “wrap_content” in a dimension alias, you should use “-1dp” or “-2dp” project-folder/res/values/dimen.xml <resources> <dimen name="my_dimen>@dimen/match_parent</dimen> <dimen name="match_parent">-1dp</dimen> <dimen name="wrap_content">-2dp</dimen> </resources> project-folder/res/values-sw600dp/layout.xml <resources> <dimen name="my_dimen>300dp</dimen> </resources> Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 78. Listener Hell If you have to many listeners or you think the programming model is old school like the “goto statements”. Give message/ event/ service bus a try. For Android: Otto from Square EventBus from greenrobot See also: Callbacks as our Generations' Go To Statement Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 79. Custom Theme & Style Android Ui Utils Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 80. ActionBar Style Generator Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 81. Holo Color Generator Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 82. Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel
  • 83. Mission Accomplished ? Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel http://www.flickr.com/photos/ianaberle/5729561934/
  • 84. Mission Accomplished Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel http://www.flickr.com/photos/ianaberle/5729561934/
  • 85. Q&A Page 85 Droidcon IT 2014 | Develop for different device classifications | Hasan Hosgel Source: http://www.flickr.com/photos/21496790@N06/5065834411/
  • 86. www.immobilienscout24.de Thanks for your attention! Contact: +HasanHosgel Twitter: @alosdev Github: alosdev Best Practices to develop for different Android Device Classifications https://github.com/alosdev/multidevice-nightmare-demo http://www.slideshare.net/hosgel/droidcon-it-2014-best-practices-to-develop-fordifferent-android-device-classifications