SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Architecture your Android Application Mark Brady
Structure ,[object Object]
10 Minutes of Q&A
Source Code: http://github.com/zedray/Android-Framework-Prototype/
Market App Framework Prototype [BETA]
About Me ,[object Object]
Android developer at Vodafone
Background in web design, back-end development and Java ME
Android Blog: http://blog.zedray.com/category/android/ “ Quick Dial / Call Log Widget”
Overview ,[object Object]
[object Object],[object Object]
Lack of guidance on how to use them. Service Application Activity
Activity #1 ,[object Object],1 2 3 4 Home Screen
Activity #2 ,[object Object],3 4 Bundle Bundle
Activity #3 ,[object Object],Bundle Bundle 2 3 4
Activity #4 ,[object Object]
Running onStart() - onStop()
Finishing onStop() and onDestroy() may not be called if a process is killed (i.e. due to low memory)
Activity #5 ,[object Object]
Do long running work in AsyncTask Separate non-UI thread will avoid ANR error.
Activity #6 ,[object Object]
Code from multiple activities can be running in the background. No good definition for when an application  has finished .
[object Object],[object Object],Time 1 2 3 4 3
[object Object],[object Object],Long running services invite “Service Killer” applications. Time
[object Object],[object Object],Time UI Broadcast Receiver
[object Object],[object Object],Think about “User Goals” during your design.
[object Object],[object Object],Old execution model, i.e. not very Android . Application 1 2 3 4 3
[object Object],1 2 3 2
Communicating between components ,[object Object]
Singletons
Handlers
Service binding
Remote procedure calls (i.e. AIDL) ,[object Object]
If you think your application is an exception: “Drag me to Hell - Optimizations for AIDL” Ronan Schwarz, Tic Mobile, 5.30pm. (Android Interface Definition Language)

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Android Training Report
Android Training ReportAndroid Training Report
Android Training Report
 
Android overview
Android overviewAndroid overview
Android overview
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Android Report
Android ReportAndroid Report
Android Report
 
Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android
 
Android seminar report
Android seminar reportAndroid seminar report
Android seminar report
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Android Overview
Android OverviewAndroid Overview
Android Overview
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Android summer training report
Android summer training reportAndroid summer training report
Android summer training report
 
ANDROID
ANDROIDANDROID
ANDROID
 
Android seminar-report-body.doc
Android seminar-report-body.docAndroid seminar-report-body.doc
Android seminar-report-body.doc
 
Seminar Report on Android OS
Seminar Report on Android OSSeminar Report on Android OS
Seminar Report on Android OS
 
Android OS
Android OSAndroid OS
Android OS
 
Introduction to Android - Mobile Portland
Introduction to Android - Mobile PortlandIntroduction to Android - Mobile Portland
Introduction to Android - Mobile Portland
 
Short notes of android
Short notes of androidShort notes of android
Short notes of android
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Android OS PPT
Android OS PPTAndroid OS PPT
Android OS PPT
 
Android versions
Android versionsAndroid versions
Android versions
 

Ähnlich wie Architecture your android_application

Android service, aidl - day 1
Android service, aidl - day 1Android service, aidl - day 1
Android service, aidl - day 1
Utkarsh Mankad
 
Threads handlers and async task, widgets - day8
Threads   handlers and async task, widgets - day8Threads   handlers and async task, widgets - day8
Threads handlers and async task, widgets - day8
Utkarsh Mankad
 

Ähnlich wie Architecture your android_application (20)

DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 
Android101
Android101Android101
Android101
 
Android service, aidl - day 1
Android service, aidl - day 1Android service, aidl - day 1
Android service, aidl - day 1
 
Inter Process Communication (IPC) in Android
Inter Process Communication (IPC) in AndroidInter Process Communication (IPC) in Android
Inter Process Communication (IPC) in Android
 
4Developers: Dominik Przybysz- Message Brokers
4Developers: Dominik Przybysz- Message Brokers4Developers: Dominik Przybysz- Message Brokers
4Developers: Dominik Przybysz- Message Brokers
 
Threads handlers and async task, widgets - day8
Threads   handlers and async task, widgets - day8Threads   handlers and async task, widgets - day8
Threads handlers and async task, widgets - day8
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
How to build typing indicator in a Chat app
How to build typing indicator in a Chat appHow to build typing indicator in a Chat app
How to build typing indicator in a Chat app
 
AIDL - Android Interface Definition Language
AIDL  - Android Interface Definition LanguageAIDL  - Android Interface Definition Language
AIDL - Android Interface Definition Language
 
Background Tasks with Worker Service
Background Tasks with Worker ServiceBackground Tasks with Worker Service
Background Tasks with Worker Service
 
Android Training (Services)
Android Training (Services)Android Training (Services)
Android Training (Services)
 
Java Svet - Communication Between Android App Components
Java Svet - Communication Between Android App ComponentsJava Svet - Communication Between Android App Components
Java Svet - Communication Between Android App Components
 
Java Svet - Communication Between Android App Components
Java Svet - Communication Between Android App ComponentsJava Svet - Communication Between Android App Components
Java Svet - Communication Between Android App Components
 
The Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework EvolutionThe Next Step in AS3 Framework Evolution
The Next Step in AS3 Framework Evolution
 
Micronaut Launchpad
Micronaut LaunchpadMicronaut Launchpad
Micronaut Launchpad
 
Projet d'accès aux résultats des étudiant via client mobile
Projet d'accès aux résultats des étudiant via client mobile Projet d'accès aux résultats des étudiant via client mobile
Projet d'accès aux résultats des étudiant via client mobile
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Architecture your android_application

  • 1. Architecture your Android Application Mark Brady
  • 2.
  • 5. Market App Framework Prototype [BETA]
  • 6.
  • 8. Background in web design, back-end development and Java ME
  • 9. Android Blog: http://blog.zedray.com/category/android/ “ Quick Dial / Call Log Widget”
  • 10.
  • 11.
  • 12. Lack of guidance on how to use them. Service Application Activity
  • 13.
  • 14.
  • 15.
  • 16.
  • 18. Finishing onStop() and onDestroy() may not be called if a process is killed (i.e. due to low memory)
  • 19.
  • 20. Do long running work in AsyncTask Separate non-UI thread will avoid ANR error.
  • 21.
  • 22. Code from multiple activities can be running in the background. No good definition for when an application has finished .
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 33.
  • 34. If you think your application is an exception: “Drag me to Hell - Optimizations for AIDL” Ronan Schwarz, Tic Mobile, 5.30pm. (Android Interface Definition Language)
  • 35. Java Singletons Flip side of running in on process/JVM is that objects in other components can be called as singletons: public class SingletonObject { private static SingletonObject ref; private SingletonObject() { // Do nothing. } public static SingletonObject getSingletonObject() { if (ref == null) { ref = new SingletonObject(); } return ref; } } Calling your singleton SingletonObject obj = SingletonObject.getSingletonObject();
  • 36.
  • 37.
  • 38. Calling Serivce.onBind() will create a Service that will remain running for as long as the ServiceConnection is established, or until a corresponding Service.onUnbind() is called. Service
  • 39.
  • 40. Service binding #3 Bind to this Service: mContext.bindService(new Intent(mContext, MyService.class), mServiceConnection, Context.BIND_AUTO_CREATE); Unbind from this Service: mContext.unbindService(mServiceConnection); Monitor Service Connection: private final ServiceConnection mServiceConnection = new ServiceConnection() { public void onServiceConnected(final ComponentName className, final IBinder service) { mHandler = ((MyService.MyBinder) service).getHandler(); } public void onServiceDisconnected(final ComponentName className) { mHandler = null; } }; Service
  • 41.
  • 43. Market App Framework Prototype [BETA]
  • 47.
  • 48. State Handled in a single place, so implement database synchronization here.
  • 49. Worker Thread Call stopSelf() as soon as all user goals are complete.
  • 50. Source Code – BaseActivity #1 public class MyActivity extends BaseActivity { @Override public final void onCreate(final Bundle savedInstanceState) { // Database I/O. getCache() .getSomeStateValue(); getDb() .setSomeStateValue("Foo", "Bar"); } @Override protected final void onResume() { // Update the UI on resume. updateUi(); super.onResume(); } ...
  • 51. Source Code – BaseActivity #2 ... public final void doSomeTask() { // Post something to Service queue. getServiceQueue().postToService (Type.DO_SOME_TASK, null); } @Override public final void post (final Type type, final Bundle bundle) { // Implement an incoming UI message, depending on type. switch (type) { case SHOW_SOME_UI: showSomeUi(); break; case UPDATE_UI: updateUi(); break; default: /** Let the BaseActivity handle other message types. */ super.post(type, bundle); break; } } }
  • 52. Source Code – WorkerThread #1 public class WorkerThread extends Thread { public final void run() { while ( mWorkQueue .size() > 0) { synchronized ( mWorkQueue ) { // Remove a task from the queue. Message message = mWorkQueue .remove(0); ... } // Do the task, depending on type. switch (type) { case DO_SOME_TASK: doSomeTask(bundle); break; } } // No work to do, so kill the service. mMyService .stopSelf(); } ...
  • 53. Source Code – WorkerThread #2 ... private void doSomeTask(final Bundle bundle) { mCache .setState("Loading"); mUiQueue . postToUi (Type.UPDATE_UI, null, true); // Do some setup work. ... mCache .setState("Running"); mUiQueue . postToUi (Type.UPDATE_UI, null, true); // Do some real work. ... mCache .setState("Finished"); mUiQueue.postToUi (Type.UPDATE_UI, null, true); if (someCondition) { // Show some custom UI (do not suppress). mUiQueue.postToUi (Type.SHOW_SOME_UI, null, false ); } } }
  • 54.
  • 56. Market App Framework Prototype [BETA]