SlideShare una empresa de Scribd logo
1 de 63
1
Android2EE est référencé en tant qu’organisme de formation, vous pouvez faire prendre en charge tout ou partie du montant de cette
formation par votre OPCA. Cette formation Initiation avancée à Android est éligible au titre du DIF et CIF.
Lieu : Paris, Toulouse, Lyon,
Rennes, Nantes, Lille
Durée : 3 jours
Prix : 1680 €
Lieu : Paris, Toulouse, Lyon,
Rennes, Nantes, Lille
Durée : 5 jours
Prix : 2980 €
Lieu : Paris, Toulouse, Lyon,
Rennes, Nantes, Lille
Durée : 3 jours
Prix : 1780 €
3
4
0
10
20
30
40
50
60
70
Telephone Electricity Computer Mobile phone internet Radio Television Smartphone Tablet
Taux de pénétration (G8)
10% time from 10% to 40%
5
Penetration rate to reach 40% of the population for a technology (G8)
•They are still at "the earth is flat"
•Do not know how Android works
•Do not use it
•Want what they already have (IOs)
•Underestimate the complexity
6
Educate
Communicate
Listen
Collaborate
7
8
9
10
Why ?
Backup and restore the user context
Data backup
Build links between your users
And a lot of others good reasons...
11
What your users think about it
12
1.The ghost mode:
UUID
and
SharedPreferenceBackup
Benefits:
No password,
Works everywhere with every users,
Real authentification
Multi-devices
Disadvantages:
No Name
13
2.The native Android mode:
Google Authentification
Benefits:
No password, No Permission needed
Works everywhere with every users,
Real authentification
User have a name
14
3.The Social mode:
Facebook, Twitter and co
Disadvantages:
Need password (sometimes),
Don't work with every users,
Need a social user
Benefits:
Real authentification
User have a name
15
4.The hardcore mode:
OAuth FROM scratch
(hard and bleeding)
Disavantages:
Need password, user name
Hard to code, Hard to maintain
Bleeding
NEED SKILL
Benefits:
Sometimes there is no other choice
16
You user is
Bruce Wayne
Your application behaves as
Alfred or Lucius
Through you
Your user becomes
!--Style for TextView-->
<!-- ************************-->
<style name=“mainTxv“ parent="@android:style/TextAppearance">
<item name=“android:textSize“>12sp</item>
<item name=“android:textStyle“>bold</item>
<item name=“android:background“>"@color/background"</item>
<item name=“android:paddingLeft“>3dip</item>
<item name=“android:paddingRight“>3dip</item>
<item name=“android:textColor“> "@color/foreground" </item>
<item name=“android:layout_width“>wrap_content</item>
<item name=“android:layout_height“>wrap_content</item>
</style>
<style name=“mainEdt“ parent="mainTxv">
<item name=“android:textSize“>12sp</item>
<item name=“android:textStyle“>bold</item>
</style>
17
Manage your ressources, they are your best friends: Inherit, redirect, smile
MyBaseTheme
Theme Theme.Holo
MyThemeColorChart RefColors
RefDimensions Style
TxvStyle TxvTitleStyle
EdtStyle
BtnStyle
And so on
TxvWarningStyle
TxvErrorStyle
EdtTitleStyle
EdtWarningStyle
EdtErrorStyle
BtnTitleStyle
BtnWarningStyle
<TextView
style=“@style/ TxvStyle“
android:text=“@string/hello“ />
Use custom toast and custom AlertDialog
Always customize native elements of your application: Slider, Toast, ActionBar, DropDown,...
18
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Light.JCertif" parent="android:style/Theme.Holo.Light">
<item name="android:dropDownItemStyle">@style/Widget.DropDownItemLight</item>
</style>
<style name="Theme.Light.JCertif.preHC" parent="android:style/Theme.NoTitleBar">
<item name="android:dropDownItemStyle">@style/Widget.DropDownItemLight</item>
</style>
<style name="Widget.DropDownItemLight" parent="@android:style/Widget.DropDownItem">
<item name="android:textColor">@color/deep_blue</item>
<item name="android:textSize">@dimen/textSize</item>
<item name="android:textStyle">italic</item>
</style>
</resources>
http://developer.android.com/design/downloads/index.html
http://blog.stylingandroid.com/archives/1267
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml
http://www.androidviews.net/category/dev-tools/
http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html
private void myMakeText() {
LayoutInflater inflater = getLayoutInflater();
View layout =
getLayoutInflater().inflate(R.layout.toast_layout, );
Toast toast = new Toast(this);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
Use Tools and ressources
19
20
Only code what you need
Focus on main features
Limit features
No generic stuff for future/for fun
No gaz factory for future feature
No complex mechanism for evolutivity
Only load what you need
when you need it
Use ViewsStub
Use Dynamic Fragment
Never use NestedFragments
21
22
Interface, factory implementation
if(postHoneyComb)
if(postJellyBean)
if(postKitKat)
Factory
Implementation
Interface
Client
resvaluesversions.xml
<resources>
<bool name="postHoneyComb">false</bool>
<bool name="postJellyBean">false</bool>
<bool name="postKitKat">false</bool>
</resources>
resvalues-v11versions.xml
<resources>
<bool name="postHoneyComb">true</bool>
<bool name="postJellyBean">false</bool>
<bool name="postKitKat">false</bool>
</resources>
resvalues-v16versions.xml
<resources>
<bool name="postHoneyComb">true</bool>
<bool name="postJellyBean">true</bool>
<bool name="postKitKat">false</bool>
</resources>
knows
ask for
real
returns the
implementation adapted
to the version context
23
Fight against memory leaks
Thread I.H.M Thread de traitement
Activity Handler
sendMessage()
message
Thread I.H.M
Thread de traitement
Activity
sendMessage()
message
Handler
OnDestroy()
OnCreate()
Thread de traitement initiale
sendMessage()
Activity
fantôme
Handler
fantôme
24
Fight against memory leaks
25
Centralize your thread management
/** * The ThreadPool Executor for caching background */
ExecutorService executor = Executors.newFixedThreadPool(6,
new BackgroundThreadFactory());
/** * And its associated factory */
public class BackgroundThreadFactory implements ThreadFactory {
public Thread newThread(Runnable r) {Thread t = new Thread(r);return t;}
}
/** * This method draw the background and store it in a bitmap that can be reused */
public synchronized void cacheBackGround() {
executor.submit(mCacheBackgroundRunnnable);
}
Fight against memory leaks
MyApplication
PoolExecutor
Never let a thread unmanaged:
Use PoolExecutor
Always know when the thread needs to finish and ensure its death
void cleanMemory() {if (executor != null) {
executor.shutdown(); // Disable new tasks from being submitted
try {//as long as your threads hasn't finished
while (!executor.isTerminated()) {
// Wait a while for existing tasks to terminate
if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {
// Cancel currently executing tasks
executor.shutdownNow();
Log.e("MyApp","Probably a memory leak here");
}
}
} catch (InterruptedException ie) {
// (Re-)Cancel if current thread also interrupted
executor.shutdownNow();
// Preserve interrupt status
Thread.currentThread().interrupt();
Log.e("MyApp","Probably a memory leak here too");
}}}
<receiver android:name="DeviceStateReceiever" >
<action android:name="ACTION_DOCK_EVENT" />
<action android:name="ACTION_BATTERY_LOW" />
<action android:name="ACTION_POWER_CONNECTED" />
<action android:name="ACTION_POWER_DISCONNECTED" />
<action android:name="CONNECTIVITY_CHANGE" />
<action android:name="BOOT_COMPLETED" />
<action android:name="wifi.STATE_CHANGE" />
</receiver> store
MyApplication
Persistence
BraodCastReceiver
listen
BootAndWifi Receiever
27
if(Wifi) if(NoWifi) if(NoConnection)
Factory
Implementation
Com
Interface
knows
ask for
real
returns the implementation adapted to the
connection context
MyApplication
Server
Backend
send your com
context
receive
PrefetchData
load
first
cach
after
receive your com
status
Persistence
BootAndWifi Receiever
BigCookies strategy
State Design Pattern
28
Never use nested fragments (launch a new activity instead)
Fragments: Redirect layout and set in stone the number of fragments displayed
•reslayout
activity_a_two_panes_layout.xml (le vrai layout)
activity_a_one_panes_layout.xml (le vrai layout)
layout_redirection.xml
<resources>
<item name="main_activity" type="layout">@layout/activity_one_panes</item>
<bool name="twoPane">false</bool>
</resources>
Dans ActivityA
setContentView(R.layout.main_activity)
•reslayout-land||reslayout-large||reslayout-xlarge
layout_redirection.xml
<resources>
<item name="main_activity" type="layout">@layout/activity_two_panes</item>
<bool name="twoPane">true</bool>
</resources>
getRessource().getBoolean(R.bool.twoPane)
29
30
but 80% of us don't know how to do it the right way
so use SQLCipher (Mark Murphy)
31
& Don't make parrallel pattern when using support-librairy:
use only support lib (no code replication)
32
ManagedException
Exception
ManagedException
isManaged
UserId
User error
message
Technical data
Functional
data
Others stuff
33
ManagedException
ExceptionManager
MotherActivity implements ExceptionEvent
to display exception automagicly
Exception
Manager
ExceptionManager.manage
Team FeedBackUser FeedBack
SomeWhere in your code galaxy
34
Add version to your servlet url
/myservlet_v1.2
MyOnlyObject in Json+GZip
Add timestamp to your data (your database)
Request data based on your timestamp
Use json + gzip
It's on server side that prefetch is done (depending on the connectivity status)
TimeStamp
TimeStamp
/myservlet_v1.2?timespan=11215982/myservlet_v1.2?timespan=11215982&net=wifi
Add you connectivity status in your request
Use the big cookies strategy
Manage your DataBase size.
Never exceed :
SQLiteDataBase.getMaximumSize()
35
36
And I want to Lazy Load every think
When my app is in foreground I want the max available memory when I need it
When my app goes in background I want to realease my memories
Fuck I am
going in
background
Take that
services !
Application
Services
View Model
AndroidServices
SingletonServices
BroadcastReceiver
ExceptionManager
POJO
Tools
knows
knows
knows
starts
starts
knows
View
Service Communication
Com
D.A.O.
DAO
Transverse
private void launchServiceAsync() {
// load your service...
ServiceManager.instance.getHumanService(new OnServiceCallBack() {
public void onServiceCallBack(MService service) {
// so just call the method you want of your service
((HumanService) service).getHuman("toto");
}});}
the callBack pattern
38
View Model
HumanService
LazyLoading
Services
Manager
Activity
Application
39
View Model
HumanService
LazyLoading
Services
Manager
IsActivity
Alive
40
The release memory pattern.
Application
View
Services
Manager
onStop
onStart
Runnable mServiceKiller;
Launch it
In1Second
if(false) unbindAndDie()
if false
/** Destructor **/
/** * This method is called by MApplication to unbind all
the services and let them die when your application die */
public synchronized void unbindAndDie() {
// Browse all the services and unbind them all
for (ServiceConnection sConn : boundServices) {
//first unbind the service
unbindService(sConn);}
dService = null;boundServices.clear();}
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
public void onActivityStopped(Activity activity) {isActivityAlive.set(false);}
public void onActivityCreated(Activity activity) {isActivityAlive.set(true);}});
// launch the Runnable mServiceKiller in 1 seconds
getServiceKillerHanlder().postDelayed(getServiceKiller(), 1000);
IsActivity
Alive
41
The release memory principle.
ApplicationServices
Manager
onLowMemory (...)
System
unbindAndDie()
You are lazy loading your services, so you can kill them at any time,
they will be reloaded if needed.
42
every one wants to be asynchronous:
So Views launch Threads,
Services launch Threads,
Com launch Threads,
D.A.O launch Threads,
It gives Thread(Thread(Thread(Thread{Do the work})))
We are at the top !
43
44
Activty's methods need to be split each time a call to services is done
Services
View Model
doSomething()
{
//code...
Human hum =getHumanService().getHuman("toto");
//other code using hum
txvHumanName.setText(hum.getName());
}
call
Failed
It's asynchronous
What we used to do
before
45
Activty's methods need to be split each time a call to services is done
Services
View Model
doSomething()
{ //code...
getHumanService().getHuman("toto");
}
call
What we need to do now
doSomethingPart2(Human hum)
{
//other code using hum
txvHumanName.setText(hum.getName());
}
async return
Yes
good way
46
Services
Buisness services have to
Finish their threatments
Be instanciate on demand
Persist their instanciation
not follow activities lifecycle but follow application life cycle
Keep in LRU if active as
long as possible
47
Services
AndroidServicesSingletonServices
?
System
Need to be launched by the system ?
Need to cach data?
No particular need
Insure unique
instanciation (best to do
that using the
application instead of
static)
G.U.I. Thread Background Thread
View Model
ServiceData
DataCom
DataDao
Services
Manager
ServiceUpdater
call
BIND
START
load
return data
Intent|Event
call
return data
Caching
return data
fire
DataUpdateEvent
Intent
ContentObserver
49
DataDaoServiceUpdater
push Message
GoogleCloud
Messaging
When new data need to be broadcasted
+PayLoad + Token (DataVersion)
store
But sometimes GCM failed to deliver message
Backend server
BroadcastReceiver
start
WakeUp!
You are up to date!
50
Use a library because you have too, not for fun
Less library your project have, better you are
Choose carefully your lib, it's critical, don't mess around
52
Never use annotations at runtime
1 librairy = 1 feature = 1 goal
Don't use library that does too much when you use 1% of it
Don't use unmaintained library
If you can copy/paste the code within your project it's better
because it means it's a simple library that does what it have too without a gaz factory. (But don't copy/paste
code anyway for bug corrections reasons)
53
Use Square Libraries (http://square.github.io/)
• Dagger (injection),
• Otto (event bus),
• Picasso (translator helper),
• OkHttp (HttpClient),
• RetroFit (Rest client),
• seismic (shake detection),
• wire (protocol buffer),
• spoon (testing),
• retrofit (testing)
54
Use Square Libraries (http://square.github.io/)
Use GooglePlayServices (even if it's beta like)
Use Haptic library (for your user): Immersion (http://www.immersion.com/haptic/sdk)
Use SqlCipher to encrypt your database and your sharedPreferences
Use EventBus, Gson, Jackson, Sax, Dom when needed
Use Crashlytics or ACCRA for bug reporting/tracking
Go and see http://www.androidviews.net/category/libraries/
A lot of View libraries are available
Go and see : Android Project on Github
https://plus.google.com/communities/100609058582053363304
Genymotion instead of native emulators
For librairy without reputation, always check the code
Try not to mix too much librairies (redundency, dependencies conflict)
55
56
For the build system :
flavors
script done by the community
modularity
57
58
59
Use GIT
Use Gradle
Do continous integration (Jenkins)
Use the Android Test SDK
Use Robotium || expresso || RoboElectric
Have a look at Rational Mobile (if you are CapGemini)
Use your users (Alpha and Beta channel on PlayStore)
60
GoogleAnalyticsTracker
Flurry
AppSee
Apsalar
Read this little story :
A lire le http://thenextweb.com/dd/2014/04/08/ux-designers-side-drawer-navigation-costing-half-user-
engagement/?utm_source=social
A/B testing
61
Build
Deploy
Users
feedback
Learn
Improve
62
http://blog.cloudmagic.com/2014/02/11/3
0-android-developers-and-experts-to-
follow-on-twitter/
63
#android2ee
mathias.seguy@android2ee.com
www.android2ee.com

Más contenido relacionado

Destacado

Android2EE training: Tutorials list of Android projects
Android2EE training: Tutorials list of Android projectsAndroid2EE training: Tutorials list of Android projects
Android2EE training: Tutorials list of Android projectsMathias Seguy
 
Treatment, Architecture and Threads
Treatment, Architecture and ThreadsTreatment, Architecture and Threads
Treatment, Architecture and ThreadsMathias Seguy
 
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2Mathias Seguy
 
Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...
Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...
Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...Mathias Seguy
 
ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013Mathias Seguy
 
The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]Nilhcem
 
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Mathias Seguy
 
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...Mathias Seguy
 
Animate me, If you don't do it for me do it for Chet :)
Animate me, If you don't do it for me do it for Chet :)Animate me, If you don't do it for me do it for Chet :)
Animate me, If you don't do it for me do it for Chet :)Mathias Seguy
 
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC BelgiquePrésentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC BelgiqueDenis Voituron
 
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1Mathias Seguy
 
Android un nouveau futur s'ouvre à nous
Android un nouveau futur s'ouvre à nousAndroid un nouveau futur s'ouvre à nous
Android un nouveau futur s'ouvre à nousMathias Seguy
 

Destacado (12)

Android2EE training: Tutorials list of Android projects
Android2EE training: Tutorials list of Android projectsAndroid2EE training: Tutorials list of Android projects
Android2EE training: Tutorials list of Android projects
 
Treatment, Architecture and Threads
Treatment, Architecture and ThreadsTreatment, Architecture and Threads
Treatment, Architecture and Threads
 
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part2
 
Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...
Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...
Conférence "Architecture Android" du 19 Mars 2013 par Mathias Seguy fondateur...
 
ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013
 
The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]The 2016 Android Developer Toolbox [NANTES]
The 2016 Android Developer Toolbox [NANTES]
 
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
Animate Me! if you don't do it for me, do it for Chet - DroidconLondon2015
 
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...
Eclispe daytoulouse combining the power of eclipse with android_fr_1024_768_s...
 
Animate me, If you don't do it for me do it for Chet :)
Animate me, If you don't do it for me do it for Chet :)Animate me, If you don't do it for me do it for Chet :)
Animate me, If you don't do it for me do it for Chet :)
 
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC BelgiquePrésentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
 
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1
Architecture et Bonnes pratiques Android #DevoxxFr2016 Part1
 
Android un nouveau futur s'ouvre à nous
Android un nouveau futur s'ouvre à nousAndroid un nouveau futur s'ouvre à nous
Android un nouveau futur s'ouvre à nous
 

Similar a Voyage en monde Android. Trucs et astuces tout au long de la route.

Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on MobileAdam Lu
 
Java Technology
Java TechnologyJava Technology
Java Technologyifnu bima
 
jAPS 2 0 - Presentation Layer Comparison
jAPS 2 0 - Presentation Layer ComparisonjAPS 2 0 - Presentation Layer Comparison
jAPS 2 0 - Presentation Layer ComparisonWilliam Ghelfi
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsNathan Smith
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016Loïc Knuchel
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology updateDoug Domeny
 
Developing for LinkedIn's Application Platform
Developing for LinkedIn's Application PlatformDeveloping for LinkedIn's Application Platform
Developing for LinkedIn's Application PlatformTaylor Singletary
 
Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....
Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....
Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....Patrick Lauke
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptMobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptfranksvalli
 
Gradle for Android Developers
Gradle for Android DevelopersGradle for Android Developers
Gradle for Android DevelopersJosiah Renaudin
 
He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!François-Guillaume Ribreau
 
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android AppsUsing Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android AppsLuis Cruz
 

Similar a Voyage en monde Android. Trucs et astuces tout au long de la route. (20)

Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
HTML5 on Mobile
HTML5 on MobileHTML5 on Mobile
HTML5 on Mobile
 
Java Technology
Java TechnologyJava Technology
Java Technology
 
jAPS 2 0 - Presentation Layer Comparison
jAPS 2 0 - Presentation Layer ComparisonjAPS 2 0 - Presentation Layer Comparison
jAPS 2 0 - Presentation Layer Comparison
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
Ionic2, les développeurs web à l'assaut du mobile, BDX I/O le 21/10/2016
 
Api
ApiApi
Api
 
HTML5와 모바일
HTML5와 모바일HTML5와 모바일
HTML5와 모바일
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
Developing for LinkedIn's Application Platform
Developing for LinkedIn's Application PlatformDeveloping for LinkedIn's Application Platform
Developing for LinkedIn's Application Platform
 
Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....
Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....
Handys und Tablets - Webentwicklung jenseits des Desktops - WebTech Mainz 12....
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Taking your Web App for a walk
Taking your Web App for a walkTaking your Web App for a walk
Taking your Web App for a walk
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptMobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScript
 
Gradle for Android Developers
Gradle for Android DevelopersGradle for Android Developers
Gradle for Android Developers
 
He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!He stopped using for/while loops, you won't believe what happened next!
He stopped using for/while loops, you won't believe what happened next!
 
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android AppsUsing Automatic Refactoring to Improve Energy Efficiency of Android Apps
Using Automatic Refactoring to Improve Energy Efficiency of Android Apps
 
前端概述
前端概述前端概述
前端概述
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
 

Último

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Último (20)

Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

Voyage en monde Android. Trucs et astuces tout au long de la route.

  • 1. 1
  • 2. Android2EE est référencé en tant qu’organisme de formation, vous pouvez faire prendre en charge tout ou partie du montant de cette formation par votre OPCA. Cette formation Initiation avancée à Android est éligible au titre du DIF et CIF. Lieu : Paris, Toulouse, Lyon, Rennes, Nantes, Lille Durée : 3 jours Prix : 1680 € Lieu : Paris, Toulouse, Lyon, Rennes, Nantes, Lille Durée : 5 jours Prix : 2980 € Lieu : Paris, Toulouse, Lyon, Rennes, Nantes, Lille Durée : 3 jours Prix : 1780 €
  • 3. 3
  • 4. 4
  • 5. 0 10 20 30 40 50 60 70 Telephone Electricity Computer Mobile phone internet Radio Television Smartphone Tablet Taux de pénétration (G8) 10% time from 10% to 40% 5 Penetration rate to reach 40% of the population for a technology (G8) •They are still at "the earth is flat" •Do not know how Android works •Do not use it •Want what they already have (IOs) •Underestimate the complexity
  • 7. 7
  • 8. 8
  • 9. 9
  • 10. 10 Why ? Backup and restore the user context Data backup Build links between your users And a lot of others good reasons...
  • 11. 11 What your users think about it
  • 12. 12 1.The ghost mode: UUID and SharedPreferenceBackup Benefits: No password, Works everywhere with every users, Real authentification Multi-devices Disadvantages: No Name
  • 13. 13 2.The native Android mode: Google Authentification Benefits: No password, No Permission needed Works everywhere with every users, Real authentification User have a name
  • 14. 14 3.The Social mode: Facebook, Twitter and co Disadvantages: Need password (sometimes), Don't work with every users, Need a social user Benefits: Real authentification User have a name
  • 15. 15 4.The hardcore mode: OAuth FROM scratch (hard and bleeding) Disavantages: Need password, user name Hard to code, Hard to maintain Bleeding NEED SKILL Benefits: Sometimes there is no other choice
  • 16. 16 You user is Bruce Wayne Your application behaves as Alfred or Lucius Through you Your user becomes
  • 17. !--Style for TextView--> <!-- ************************--> <style name=“mainTxv“ parent="@android:style/TextAppearance"> <item name=“android:textSize“>12sp</item> <item name=“android:textStyle“>bold</item> <item name=“android:background“>"@color/background"</item> <item name=“android:paddingLeft“>3dip</item> <item name=“android:paddingRight“>3dip</item> <item name=“android:textColor“> "@color/foreground" </item> <item name=“android:layout_width“>wrap_content</item> <item name=“android:layout_height“>wrap_content</item> </style> <style name=“mainEdt“ parent="mainTxv"> <item name=“android:textSize“>12sp</item> <item name=“android:textStyle“>bold</item> </style> 17 Manage your ressources, they are your best friends: Inherit, redirect, smile MyBaseTheme Theme Theme.Holo MyThemeColorChart RefColors RefDimensions Style TxvStyle TxvTitleStyle EdtStyle BtnStyle And so on TxvWarningStyle TxvErrorStyle EdtTitleStyle EdtWarningStyle EdtErrorStyle BtnTitleStyle BtnWarningStyle <TextView style=“@style/ TxvStyle“ android:text=“@string/hello“ />
  • 18. Use custom toast and custom AlertDialog Always customize native elements of your application: Slider, Toast, ActionBar, DropDown,... 18 <?xml version="1.0" encoding="utf-8"?> <resources> <style name="Theme.Light.JCertif" parent="android:style/Theme.Holo.Light"> <item name="android:dropDownItemStyle">@style/Widget.DropDownItemLight</item> </style> <style name="Theme.Light.JCertif.preHC" parent="android:style/Theme.NoTitleBar"> <item name="android:dropDownItemStyle">@style/Widget.DropDownItemLight</item> </style> <style name="Widget.DropDownItemLight" parent="@android:style/Widget.DropDownItem"> <item name="android:textColor">@color/deep_blue</item> <item name="android:textSize">@dimen/textSize</item> <item name="android:textStyle">italic</item> </style> </resources> http://developer.android.com/design/downloads/index.html http://blog.stylingandroid.com/archives/1267 https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml http://www.androidviews.net/category/dev-tools/ http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html private void myMakeText() { LayoutInflater inflater = getLayoutInflater(); View layout = getLayoutInflater().inflate(R.layout.toast_layout, ); Toast toast = new Toast(this); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); } Use Tools and ressources
  • 19. 19
  • 20. 20 Only code what you need Focus on main features Limit features No generic stuff for future/for fun No gaz factory for future feature No complex mechanism for evolutivity Only load what you need when you need it Use ViewsStub Use Dynamic Fragment Never use NestedFragments
  • 21. 21
  • 22. 22 Interface, factory implementation if(postHoneyComb) if(postJellyBean) if(postKitKat) Factory Implementation Interface Client resvaluesversions.xml <resources> <bool name="postHoneyComb">false</bool> <bool name="postJellyBean">false</bool> <bool name="postKitKat">false</bool> </resources> resvalues-v11versions.xml <resources> <bool name="postHoneyComb">true</bool> <bool name="postJellyBean">false</bool> <bool name="postKitKat">false</bool> </resources> resvalues-v16versions.xml <resources> <bool name="postHoneyComb">true</bool> <bool name="postJellyBean">true</bool> <bool name="postKitKat">false</bool> </resources> knows ask for real returns the implementation adapted to the version context
  • 24. Thread I.H.M Thread de traitement Activity Handler sendMessage() message Thread I.H.M Thread de traitement Activity sendMessage() message Handler OnDestroy() OnCreate() Thread de traitement initiale sendMessage() Activity fantôme Handler fantôme 24 Fight against memory leaks
  • 25. 25 Centralize your thread management /** * The ThreadPool Executor for caching background */ ExecutorService executor = Executors.newFixedThreadPool(6, new BackgroundThreadFactory()); /** * And its associated factory */ public class BackgroundThreadFactory implements ThreadFactory { public Thread newThread(Runnable r) {Thread t = new Thread(r);return t;} } /** * This method draw the background and store it in a bitmap that can be reused */ public synchronized void cacheBackGround() { executor.submit(mCacheBackgroundRunnnable); } Fight against memory leaks MyApplication PoolExecutor Never let a thread unmanaged: Use PoolExecutor Always know when the thread needs to finish and ensure its death void cleanMemory() {if (executor != null) { executor.shutdown(); // Disable new tasks from being submitted try {//as long as your threads hasn't finished while (!executor.isTerminated()) { // Wait a while for existing tasks to terminate if (!executor.awaitTermination(60, TimeUnit.SECONDS)) { // Cancel currently executing tasks executor.shutdownNow(); Log.e("MyApp","Probably a memory leak here"); } } } catch (InterruptedException ie) { // (Re-)Cancel if current thread also interrupted executor.shutdownNow(); // Preserve interrupt status Thread.currentThread().interrupt(); Log.e("MyApp","Probably a memory leak here too"); }}}
  • 26. <receiver android:name="DeviceStateReceiever" > <action android:name="ACTION_DOCK_EVENT" /> <action android:name="ACTION_BATTERY_LOW" /> <action android:name="ACTION_POWER_CONNECTED" /> <action android:name="ACTION_POWER_DISCONNECTED" /> <action android:name="CONNECTIVITY_CHANGE" /> <action android:name="BOOT_COMPLETED" /> <action android:name="wifi.STATE_CHANGE" /> </receiver> store MyApplication Persistence BraodCastReceiver listen BootAndWifi Receiever
  • 27. 27 if(Wifi) if(NoWifi) if(NoConnection) Factory Implementation Com Interface knows ask for real returns the implementation adapted to the connection context MyApplication Server Backend send your com context receive PrefetchData load first cach after receive your com status Persistence BootAndWifi Receiever BigCookies strategy State Design Pattern
  • 28. 28 Never use nested fragments (launch a new activity instead) Fragments: Redirect layout and set in stone the number of fragments displayed •reslayout activity_a_two_panes_layout.xml (le vrai layout) activity_a_one_panes_layout.xml (le vrai layout) layout_redirection.xml <resources> <item name="main_activity" type="layout">@layout/activity_one_panes</item> <bool name="twoPane">false</bool> </resources> Dans ActivityA setContentView(R.layout.main_activity) •reslayout-land||reslayout-large||reslayout-xlarge layout_redirection.xml <resources> <item name="main_activity" type="layout">@layout/activity_two_panes</item> <bool name="twoPane">true</bool> </resources> getRessource().getBoolean(R.bool.twoPane)
  • 29. 29
  • 30. 30 but 80% of us don't know how to do it the right way so use SQLCipher (Mark Murphy)
  • 31. 31 & Don't make parrallel pattern when using support-librairy: use only support lib (no code replication)
  • 33. 33 ManagedException ExceptionManager MotherActivity implements ExceptionEvent to display exception automagicly Exception Manager ExceptionManager.manage Team FeedBackUser FeedBack SomeWhere in your code galaxy
  • 34. 34 Add version to your servlet url /myservlet_v1.2 MyOnlyObject in Json+GZip Add timestamp to your data (your database) Request data based on your timestamp Use json + gzip It's on server side that prefetch is done (depending on the connectivity status) TimeStamp TimeStamp /myservlet_v1.2?timespan=11215982/myservlet_v1.2?timespan=11215982&net=wifi Add you connectivity status in your request Use the big cookies strategy Manage your DataBase size. Never exceed : SQLiteDataBase.getMaximumSize()
  • 35. 35
  • 36. 36 And I want to Lazy Load every think When my app is in foreground I want the max available memory when I need it When my app goes in background I want to realease my memories Fuck I am going in background Take that services !
  • 38. private void launchServiceAsync() { // load your service... ServiceManager.instance.getHumanService(new OnServiceCallBack() { public void onServiceCallBack(MService service) { // so just call the method you want of your service ((HumanService) service).getHuman("toto"); }});} the callBack pattern 38 View Model HumanService LazyLoading Services Manager Activity
  • 40. IsActivity Alive 40 The release memory pattern. Application View Services Manager onStop onStart Runnable mServiceKiller; Launch it In1Second if(false) unbindAndDie() if false /** Destructor **/ /** * This method is called by MApplication to unbind all the services and let them die when your application die */ public synchronized void unbindAndDie() { // Browse all the services and unbind them all for (ServiceConnection sConn : boundServices) { //first unbind the service unbindService(sConn);} dService = null;boundServices.clear();} registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { public void onActivityStopped(Activity activity) {isActivityAlive.set(false);} public void onActivityCreated(Activity activity) {isActivityAlive.set(true);}}); // launch the Runnable mServiceKiller in 1 seconds getServiceKillerHanlder().postDelayed(getServiceKiller(), 1000); IsActivity Alive
  • 41. 41 The release memory principle. ApplicationServices Manager onLowMemory (...) System unbindAndDie() You are lazy loading your services, so you can kill them at any time, they will be reloaded if needed.
  • 42. 42 every one wants to be asynchronous: So Views launch Threads, Services launch Threads, Com launch Threads, D.A.O launch Threads, It gives Thread(Thread(Thread(Thread{Do the work}))) We are at the top !
  • 43. 43
  • 44. 44 Activty's methods need to be split each time a call to services is done Services View Model doSomething() { //code... Human hum =getHumanService().getHuman("toto"); //other code using hum txvHumanName.setText(hum.getName()); } call Failed It's asynchronous What we used to do before
  • 45. 45 Activty's methods need to be split each time a call to services is done Services View Model doSomething() { //code... getHumanService().getHuman("toto"); } call What we need to do now doSomethingPart2(Human hum) { //other code using hum txvHumanName.setText(hum.getName()); } async return Yes good way
  • 46. 46 Services Buisness services have to Finish their threatments Be instanciate on demand Persist their instanciation not follow activities lifecycle but follow application life cycle
  • 47. Keep in LRU if active as long as possible 47 Services AndroidServicesSingletonServices ? System Need to be launched by the system ? Need to cach data? No particular need Insure unique instanciation (best to do that using the application instead of static)
  • 48. G.U.I. Thread Background Thread View Model ServiceData DataCom DataDao Services Manager ServiceUpdater call BIND START load return data Intent|Event call return data Caching return data fire DataUpdateEvent Intent ContentObserver
  • 49. 49 DataDaoServiceUpdater push Message GoogleCloud Messaging When new data need to be broadcasted +PayLoad + Token (DataVersion) store But sometimes GCM failed to deliver message Backend server BroadcastReceiver start WakeUp! You are up to date!
  • 50. 50
  • 51. Use a library because you have too, not for fun Less library your project have, better you are Choose carefully your lib, it's critical, don't mess around
  • 52. 52 Never use annotations at runtime 1 librairy = 1 feature = 1 goal Don't use library that does too much when you use 1% of it Don't use unmaintained library If you can copy/paste the code within your project it's better because it means it's a simple library that does what it have too without a gaz factory. (But don't copy/paste code anyway for bug corrections reasons)
  • 53. 53 Use Square Libraries (http://square.github.io/) • Dagger (injection), • Otto (event bus), • Picasso (translator helper), • OkHttp (HttpClient), • RetroFit (Rest client), • seismic (shake detection), • wire (protocol buffer), • spoon (testing), • retrofit (testing)
  • 54. 54 Use Square Libraries (http://square.github.io/) Use GooglePlayServices (even if it's beta like) Use Haptic library (for your user): Immersion (http://www.immersion.com/haptic/sdk) Use SqlCipher to encrypt your database and your sharedPreferences Use EventBus, Gson, Jackson, Sax, Dom when needed Use Crashlytics or ACCRA for bug reporting/tracking Go and see http://www.androidviews.net/category/libraries/ A lot of View libraries are available Go and see : Android Project on Github https://plus.google.com/communities/100609058582053363304 Genymotion instead of native emulators For librairy without reputation, always check the code Try not to mix too much librairies (redundency, dependencies conflict)
  • 55. 55
  • 56. 56 For the build system : flavors script done by the community modularity
  • 57. 57
  • 58. 58
  • 59. 59 Use GIT Use Gradle Do continous integration (Jenkins) Use the Android Test SDK Use Robotium || expresso || RoboElectric Have a look at Rational Mobile (if you are CapGemini) Use your users (Alpha and Beta channel on PlayStore)
  • 60. 60 GoogleAnalyticsTracker Flurry AppSee Apsalar Read this little story : A lire le http://thenextweb.com/dd/2014/04/08/ux-designers-side-drawer-navigation-costing-half-user- engagement/?utm_source=social A/B testing

Notas del editor

  1. Et pourtant vous en avez besoin, pour sauvegarder leur donner, leur préférences et leur permettre de communiquer entre eux.
  2. Et pourtant vous en avez besoin, pour sauvegarder leur donner, leur préférences et leur permettre de communiquer entre eux.
  3. Vous ne le trahissez pas, vous êtes toujours disponible pour lui, il a confiance en vous, vous lui parlez avec gentillesse et déference tout en étant proche de lui