SlideShare a Scribd company logo
1 of 17
Titanium Mobile:
Best Practices for Android
     Josh Roesslein, Software Engineer
              Appcelerator, Inc.
        jroesslein@appcelerator.com

   Max Stepanov, Senior Software Engineer
             Appcelerator, Inc.
       mstepanov@appcelerator.com
Agenda

         • History

         • Windows and Navigation

         • Layout events

         • Event Bubbling

         • Modern Look and Feel

         • Debugging
History



          • 0.8: HTML UI / WebView

          • 0.9: Native UI / Mozilla Rhino

          • 1.8: Google V8
Windows and Navigation




                  • Heavyweight vs. Lightweight

                  • Activities and Back Stack

                  • Back Stack
Windows and Navigation


                                  Window A


                                  Window B


                     Activity A   Window B


                     Activity B


                     Activity B   Window D
Layouts


          • Eventing: Use postlayout
            NOT open

          • A layout pass may not
            have occurred by the time
            an open event is fired

          • A postlayout event occurs
            after a native Android
            layout pass (may occur
            multiple times)
Event bubbling


                 • SDK 3.0 allows control over event
                   bubbling

                 • Titanium.Event object has two new
                   properties
                    • bubbles
                    • cancelBubble

                 • Current defaults are identical to
                   2.X, but will change to achieve
                   parity in the future
Control bubbling


                   Allow custom events to bubble
                   button.fireEvent(“myEvent”,
                      {bubbles: true});



                   Allow bubbling to cancel during event
                   handling
                   view.addEventListener(“myEvent”,
                       function(e) {
                            e.cancelBubble = true;
                       })
Cancel bubbling


                  Allow views to bubble up / not to
                  bubble up events
                  view.bubbleParent = false;



                  For more information:
                  http://docs.appcelerator.com/titanium/
                  3.0/index.html#!/guide/Event_Handlin
                  g
Newer Look/Feel

•   Target API level
     •   Backwards
         compatible
     •   Unlocks newer
         behaviors and
         features

•   Themes
     •   Consistent
     •   Holo themes

•   ActionBar
     •   MenuItem
          • Action Items
     •   Tabs
          • Opt-in
          • TabGroup API
Android Debugging
New in Titanium




   Titanium 1.7      Titanium 3.0




  Android Emulator   Physical Devices
Device Debugging


                   • V8 only (for on-device debugging)



                   • Just plug in device into USB



                   • Launches faster than Emulator!
Threading

                             User taps button 1
                                                  EventListener 1
•   UI thread for handling                            var x = 1;
    user interactions                               Ti.API.log(x);
                                                     openWin(x);
•   JS thread for the        postlayout event
    application logic                              Geo location
                                                    Function         Run
•   Debugger thread for
    communications with                           EventListener 2
    Titanium Studio                                      Line 1
                                                            Line 2
•   Other Android                                           Line 3
    platform threads
Best Practices


                 • Use conditional breakpoints

                    • JavaScript code block

                    • Hit count


                 • Use Console logging with
                   Ti.API functions
Josh Roesslein & Max Stepanov

jroesslein@appcelerator.com / mstepanov@appcelerator.com

More Related Content

Viewers also liked

iPhone/iPad Development with Titanium
iPhone/iPad Development with TitaniumiPhone/iPad Development with Titanium
iPhone/iPad Development with TitaniumAxway Appcelerator
 
Codestrong 2012 breakout session how to win bigger mobile deals
Codestrong 2012 breakout session   how to win bigger mobile dealsCodestrong 2012 breakout session   how to win bigger mobile deals
Codestrong 2012 breakout session how to win bigger mobile dealsAxway Appcelerator
 
Appcelerator’s Cocoafish Acquisition and the Future of the Mobile Cloud
Appcelerator’s Cocoafish Acquisition and the  Future of the Mobile Cloud Appcelerator’s Cocoafish Acquisition and the  Future of the Mobile Cloud
Appcelerator’s Cocoafish Acquisition and the Future of the Mobile Cloud Axway Appcelerator
 
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile DevelopmentKevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile DevelopmentAxway Appcelerator
 
Codestrong 2012 breakout session exploring the new titanium command line in...
Codestrong 2012 breakout session   exploring the new titanium command line in...Codestrong 2012 breakout session   exploring the new titanium command line in...
Codestrong 2012 breakout session exploring the new titanium command line in...Axway Appcelerator
 
Desktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & RubyDesktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & RubyAxway Appcelerator
 
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Rick Blalock: Your Apps are Leaking - Controlling Memory LeaksRick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Rick Blalock: Your Apps are Leaking - Controlling Memory LeaksAxway Appcelerator
 
Mobile & The New Experience Economy (And What it Means for IT)
Mobile & The New Experience Economy  (And What it Means for IT)Mobile & The New Experience Economy  (And What it Means for IT)
Mobile & The New Experience Economy (And What it Means for IT)Axway Appcelerator
 
5 Secrets to Successfully Publishing in Appcelerator's Marketplace
5 Secrets to Successfully Publishing in Appcelerator's Marketplace5 Secrets to Successfully Publishing in Appcelerator's Marketplace
5 Secrets to Successfully Publishing in Appcelerator's MarketplaceAxway Appcelerator
 
Jacob Waller: Webifying Titanium Development
Jacob Waller: Webifying Titanium DevelopmentJacob Waller: Webifying Titanium Development
Jacob Waller: Webifying Titanium DevelopmentAxway Appcelerator
 
What’s New in Titanium Studio 1.0.7
What’s New in Titanium Studio 1.0.7What’s New in Titanium Studio 1.0.7
What’s New in Titanium Studio 1.0.7Axway Appcelerator
 

Viewers also liked (13)

Advanced titanium for i os
Advanced titanium for i osAdvanced titanium for i os
Advanced titanium for i os
 
iPhone/iPad Development with Titanium
iPhone/iPad Development with TitaniumiPhone/iPad Development with Titanium
iPhone/iPad Development with Titanium
 
Codestrong 2012 breakout session how to win bigger mobile deals
Codestrong 2012 breakout session   how to win bigger mobile dealsCodestrong 2012 breakout session   how to win bigger mobile deals
Codestrong 2012 breakout session how to win bigger mobile deals
 
Appcelerator’s Cocoafish Acquisition and the Future of the Mobile Cloud
Appcelerator’s Cocoafish Acquisition and the  Future of the Mobile Cloud Appcelerator’s Cocoafish Acquisition and the  Future of the Mobile Cloud
Appcelerator’s Cocoafish Acquisition and the Future of the Mobile Cloud
 
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile DevelopmentKevin Whinnery: Best Practices for Cross-Platform Mobile Development
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
 
Codestrong 2012 breakout session exploring the new titanium command line in...
Codestrong 2012 breakout session   exploring the new titanium command line in...Codestrong 2012 breakout session   exploring the new titanium command line in...
Codestrong 2012 breakout session exploring the new titanium command line in...
 
Desktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & RubyDesktop Applications Using HTML & JavaScript (and Python & Ruby
Desktop Applications Using HTML & JavaScript (and Python & Ruby
 
Mobile for the rest of us
Mobile for the rest of usMobile for the rest of us
Mobile for the rest of us
 
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Rick Blalock: Your Apps are Leaking - Controlling Memory LeaksRick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
 
Mobile & The New Experience Economy (And What it Means for IT)
Mobile & The New Experience Economy  (And What it Means for IT)Mobile & The New Experience Economy  (And What it Means for IT)
Mobile & The New Experience Economy (And What it Means for IT)
 
5 Secrets to Successfully Publishing in Appcelerator's Marketplace
5 Secrets to Successfully Publishing in Appcelerator's Marketplace5 Secrets to Successfully Publishing in Appcelerator's Marketplace
5 Secrets to Successfully Publishing in Appcelerator's Marketplace
 
Jacob Waller: Webifying Titanium Development
Jacob Waller: Webifying Titanium DevelopmentJacob Waller: Webifying Titanium Development
Jacob Waller: Webifying Titanium Development
 
What’s New in Titanium Studio 1.0.7
What’s New in Titanium Studio 1.0.7What’s New in Titanium Studio 1.0.7
What’s New in Titanium Studio 1.0.7
 

Similar to Codestrong 2012 breakout session android internals and best practices

Fred Spencer & Blain Hamon: Advanced Titanium for iOS
Fred Spencer & Blain Hamon: Advanced Titanium for iOSFred Spencer & Blain Hamon: Advanced Titanium for iOS
Fred Spencer & Blain Hamon: Advanced Titanium for iOSAxway Appcelerator
 
A look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processingA look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processingMatt Lacey
 
Codestrong 2012 breakout session i os internals and best practices
Codestrong 2012 breakout session   i os internals and best practicesCodestrong 2012 breakout session   i os internals and best practices
Codestrong 2012 breakout session i os internals and best practicesAxway Appcelerator
 
Infinum android talks_10_android_libraries_used_on_daily_basis
Infinum android talks_10_android_libraries_used_on_daily_basisInfinum android talks_10_android_libraries_used_on_daily_basis
Infinum android talks_10_android_libraries_used_on_daily_basisInfinum
 
Building Top-Notch Androids SDKs
Building Top-Notch Androids SDKsBuilding Top-Notch Androids SDKs
Building Top-Notch Androids SDKsrelayr
 
State Of Ajax Zend Con 08
State Of Ajax   Zend Con 08State Of Ajax   Zend Con 08
State Of Ajax Zend Con 08bgalbs
 
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014Yunong Xiao
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive uiPaul van Zyl
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOSfpatton
 
Italian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionItalian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionChris Hardy
 
HTML5 and the Future of Apps
HTML5 and the Future of AppsHTML5 and the Future of Apps
HTML5 and the Future of AppsTom Croucher
 
mobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptxmobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptxNgLQun
 
Adobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBookAdobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBookKyle McInnes
 
Infinum Android Talks #02 - EventBus
Infinum Android Talks #02 - EventBusInfinum Android Talks #02 - EventBus
Infinum Android Talks #02 - EventBusInfinum
 

Similar to Codestrong 2012 breakout session android internals and best practices (20)

Fred Spencer & Blain Hamon: Advanced Titanium for iOS
Fred Spencer & Blain Hamon: Advanced Titanium for iOSFred Spencer & Blain Hamon: Advanced Titanium for iOS
Fred Spencer & Blain Hamon: Advanced Titanium for iOS
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
A look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processingA look behind the scenes: Windows 8 background processing
A look behind the scenes: Windows 8 background processing
 
Codestrong 2012 breakout session i os internals and best practices
Codestrong 2012 breakout session   i os internals and best practicesCodestrong 2012 breakout session   i os internals and best practices
Codestrong 2012 breakout session i os internals and best practices
 
Infinum android talks_10_android_libraries_used_on_daily_basis
Infinum android talks_10_android_libraries_used_on_daily_basisInfinum android talks_10_android_libraries_used_on_daily_basis
Infinum android talks_10_android_libraries_used_on_daily_basis
 
Revue des annonces WWDC2015
Revue des annonces WWDC2015Revue des annonces WWDC2015
Revue des annonces WWDC2015
 
Efficient Android Threading
Efficient Android ThreadingEfficient Android Threading
Efficient Android Threading
 
Building Top-Notch Androids SDKs
Building Top-Notch Androids SDKsBuilding Top-Notch Androids SDKs
Building Top-Notch Androids SDKs
 
State Of Ajax Zend Con 08
State Of Ajax   Zend Con 08State Of Ajax   Zend Con 08
State Of Ajax Zend Con 08
 
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive ui
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
 
Italian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionItalian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch Session
 
Qtp - Introduction to synchronization
Qtp -  Introduction to synchronizationQtp -  Introduction to synchronization
Qtp - Introduction to synchronization
 
HTML5 and the Future of Apps
HTML5 and the Future of AppsHTML5 and the Future of Apps
HTML5 and the Future of Apps
 
mobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptxmobile development with androiddfdgdfhdgfdhf.pptx
mobile development with androiddfdgdfhdgfdhf.pptx
 
Adobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBookAdobe AIR Development for the BlackBerry PlayBook
Adobe AIR Development for the BlackBerry PlayBook
 
Eco system apps
Eco system appsEco system apps
Eco system apps
 
Infinum Android Talks #02 - EventBus
Infinum Android Talks #02 - EventBusInfinum Android Talks #02 - EventBus
Infinum Android Talks #02 - EventBus
 
Android concurrency
Android concurrencyAndroid concurrency
Android concurrency
 

More from Axway Appcelerator

Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & RoadmapAxway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & RoadmapAxway Appcelerator
 
2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff Haynie2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff HaynieAxway Appcelerator
 
Stop Debating, Start Measuring
Stop Debating, Start MeasuringStop Debating, Start Measuring
Stop Debating, Start MeasuringAxway Appcelerator
 
Apps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really MeansApps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really MeansAxway Appcelerator
 
Appcelerator Presentation Template
Appcelerator Presentation TemplateAppcelerator Presentation Template
Appcelerator Presentation TemplateAxway Appcelerator
 
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote   jonathan rende, appcelerator's vp of productsCodestrong 2012 keynote   jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote jonathan rende, appcelerator's vp of productsAxway Appcelerator
 
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Codestrong 2012 keynote   jeff haynie, appcelerator's ceoCodestrong 2012 keynote   jeff haynie, appcelerator's ceo
Codestrong 2012 keynote jeff haynie, appcelerator's ceoAxway Appcelerator
 
Codestrong 2012 keynote how to build a top ten app
Codestrong 2012 keynote   how to build a top ten appCodestrong 2012 keynote   how to build a top ten app
Codestrong 2012 keynote how to build a top ten appAxway Appcelerator
 
Codestrong 2012 breakout session at&t api platform and trends
Codestrong 2012 breakout session  at&t api platform and trendsCodestrong 2012 breakout session  at&t api platform and trends
Codestrong 2012 breakout session at&t api platform and trendsAxway Appcelerator
 
Codestrong 2012 breakout session what's new in titanium studio
Codestrong 2012 breakout session   what's new in titanium studioCodestrong 2012 breakout session   what's new in titanium studio
Codestrong 2012 breakout session what's new in titanium studioAxway Appcelerator
 
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Codestrong 2012 breakout session   using appcelerator cloud services in your ...Codestrong 2012 breakout session   using appcelerator cloud services in your ...
Codestrong 2012 breakout session using appcelerator cloud services in your ...Axway Appcelerator
 
Codestrong 2012 breakout session the role of cloud services in your next ge...
Codestrong 2012 breakout session   the role of cloud services in your next ge...Codestrong 2012 breakout session   the role of cloud services in your next ge...
Codestrong 2012 breakout session the role of cloud services in your next ge...Axway Appcelerator
 
Codestrong 2012 breakout session new device platform support for titanium
Codestrong 2012 breakout session   new device platform support for titaniumCodestrong 2012 breakout session   new device platform support for titanium
Codestrong 2012 breakout session new device platform support for titaniumAxway Appcelerator
 
Codestrong 2012 breakout session mobile platform and infrastructure
Codestrong 2012 breakout session   mobile platform and infrastructureCodestrong 2012 breakout session   mobile platform and infrastructure
Codestrong 2012 breakout session mobile platform and infrastructureAxway Appcelerator
 
Codestrong 2012 breakout session making money on appcelerator's marketplace
Codestrong 2012 breakout session   making money on appcelerator's marketplaceCodestrong 2012 breakout session   making money on appcelerator's marketplace
Codestrong 2012 breakout session making money on appcelerator's marketplaceAxway Appcelerator
 
Codestrong 2012 breakout session live multi-platform testing
Codestrong 2012 breakout session   live multi-platform testingCodestrong 2012 breakout session   live multi-platform testing
Codestrong 2012 breakout session live multi-platform testingAxway Appcelerator
 
Codestrong 2012 breakout session introduction to mobile web and best practices
Codestrong 2012 breakout session   introduction to mobile web and best practicesCodestrong 2012 breakout session   introduction to mobile web and best practices
Codestrong 2012 breakout session introduction to mobile web and best practicesAxway Appcelerator
 
Codestrong 2012 breakout session how to develop your own modules
Codestrong 2012 breakout session   how to develop your own modulesCodestrong 2012 breakout session   how to develop your own modules
Codestrong 2012 breakout session how to develop your own modulesAxway Appcelerator
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titaniumAxway Appcelerator
 

More from Axway Appcelerator (20)

Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & RoadmapAxway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
 
2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff Haynie2014 Dublin Web Summit by Jeff Haynie
2014 Dublin Web Summit by Jeff Haynie
 
Making the Mobile Mind Shift
Making the Mobile Mind ShiftMaking the Mobile Mind Shift
Making the Mobile Mind Shift
 
Stop Debating, Start Measuring
Stop Debating, Start MeasuringStop Debating, Start Measuring
Stop Debating, Start Measuring
 
Apps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really MeansApps, APIs & Analytics: What "Mobile First" Really Means
Apps, APIs & Analytics: What "Mobile First" Really Means
 
Appcelerator Presentation Template
Appcelerator Presentation TemplateAppcelerator Presentation Template
Appcelerator Presentation Template
 
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote   jonathan rende, appcelerator's vp of productsCodestrong 2012 keynote   jonathan rende, appcelerator's vp of products
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
 
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Codestrong 2012 keynote   jeff haynie, appcelerator's ceoCodestrong 2012 keynote   jeff haynie, appcelerator's ceo
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
 
Codestrong 2012 keynote how to build a top ten app
Codestrong 2012 keynote   how to build a top ten appCodestrong 2012 keynote   how to build a top ten app
Codestrong 2012 keynote how to build a top ten app
 
Codestrong 2012 breakout session at&t api platform and trends
Codestrong 2012 breakout session  at&t api platform and trendsCodestrong 2012 breakout session  at&t api platform and trends
Codestrong 2012 breakout session at&t api platform and trends
 
Codestrong 2012 breakout session what's new in titanium studio
Codestrong 2012 breakout session   what's new in titanium studioCodestrong 2012 breakout session   what's new in titanium studio
Codestrong 2012 breakout session what's new in titanium studio
 
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Codestrong 2012 breakout session   using appcelerator cloud services in your ...Codestrong 2012 breakout session   using appcelerator cloud services in your ...
Codestrong 2012 breakout session using appcelerator cloud services in your ...
 
Codestrong 2012 breakout session the role of cloud services in your next ge...
Codestrong 2012 breakout session   the role of cloud services in your next ge...Codestrong 2012 breakout session   the role of cloud services in your next ge...
Codestrong 2012 breakout session the role of cloud services in your next ge...
 
Codestrong 2012 breakout session new device platform support for titanium
Codestrong 2012 breakout session   new device platform support for titaniumCodestrong 2012 breakout session   new device platform support for titanium
Codestrong 2012 breakout session new device platform support for titanium
 
Codestrong 2012 breakout session mobile platform and infrastructure
Codestrong 2012 breakout session   mobile platform and infrastructureCodestrong 2012 breakout session   mobile platform and infrastructure
Codestrong 2012 breakout session mobile platform and infrastructure
 
Codestrong 2012 breakout session making money on appcelerator's marketplace
Codestrong 2012 breakout session   making money on appcelerator's marketplaceCodestrong 2012 breakout session   making money on appcelerator's marketplace
Codestrong 2012 breakout session making money on appcelerator's marketplace
 
Codestrong 2012 breakout session live multi-platform testing
Codestrong 2012 breakout session   live multi-platform testingCodestrong 2012 breakout session   live multi-platform testing
Codestrong 2012 breakout session live multi-platform testing
 
Codestrong 2012 breakout session introduction to mobile web and best practices
Codestrong 2012 breakout session   introduction to mobile web and best practicesCodestrong 2012 breakout session   introduction to mobile web and best practices
Codestrong 2012 breakout session introduction to mobile web and best practices
 
Codestrong 2012 breakout session how to develop your own modules
Codestrong 2012 breakout session   how to develop your own modulesCodestrong 2012 breakout session   how to develop your own modules
Codestrong 2012 breakout session how to develop your own modules
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
 

Codestrong 2012 breakout session android internals and best practices

  • 1. Titanium Mobile: Best Practices for Android Josh Roesslein, Software Engineer Appcelerator, Inc. jroesslein@appcelerator.com Max Stepanov, Senior Software Engineer Appcelerator, Inc. mstepanov@appcelerator.com
  • 2. Agenda • History • Windows and Navigation • Layout events • Event Bubbling • Modern Look and Feel • Debugging
  • 3. History • 0.8: HTML UI / WebView • 0.9: Native UI / Mozilla Rhino • 1.8: Google V8
  • 4. Windows and Navigation • Heavyweight vs. Lightweight • Activities and Back Stack • Back Stack
  • 5. Windows and Navigation Window A Window B Activity A Window B Activity B Activity B Window D
  • 6. Layouts • Eventing: Use postlayout NOT open • A layout pass may not have occurred by the time an open event is fired • A postlayout event occurs after a native Android layout pass (may occur multiple times)
  • 7. Event bubbling • SDK 3.0 allows control over event bubbling • Titanium.Event object has two new properties • bubbles • cancelBubble • Current defaults are identical to 2.X, but will change to achieve parity in the future
  • 8. Control bubbling Allow custom events to bubble button.fireEvent(“myEvent”, {bubbles: true}); Allow bubbling to cancel during event handling view.addEventListener(“myEvent”, function(e) { e.cancelBubble = true; })
  • 9. Cancel bubbling Allow views to bubble up / not to bubble up events view.bubbleParent = false; For more information: http://docs.appcelerator.com/titanium/ 3.0/index.html#!/guide/Event_Handlin g
  • 10. Newer Look/Feel • Target API level • Backwards compatible • Unlocks newer behaviors and features • Themes • Consistent • Holo themes • ActionBar • MenuItem • Action Items • Tabs • Opt-in • TabGroup API
  • 11.
  • 13. New in Titanium Titanium 1.7 Titanium 3.0 Android Emulator Physical Devices
  • 14. Device Debugging • V8 only (for on-device debugging) • Just plug in device into USB • Launches faster than Emulator!
  • 15. Threading User taps button 1 EventListener 1 • UI thread for handling  var x = 1; user interactions Ti.API.log(x); openWin(x); • JS thread for the postlayout event application logic Geo location Function Run • Debugger thread for communications with EventListener 2 Titanium Studio  Line 1 Line 2 • Other Android Line 3 platform threads
  • 16. Best Practices • Use conditional breakpoints • JavaScript code block • Hit count • Use Console logging with Ti.API functions
  • 17. Josh Roesslein & Max Stepanov jroesslein@appcelerator.com / mstepanov@appcelerator.com

Editor's Notes

  1. ----- Meeting Notes (10/22/12 13:49) -----Where the android platform has been in the past and improvements we have made over the past few years.How windows and activities work together and the differences you should know about HW and LW windows.A tip for using the "postlayout" event to query the computed layout of your views. DEMO.The new event bubbling introduced into 3.0.How to give your apps a modern look and feel. ActionBar.Finally a demo of the new device debugging support. No more slow emulator.
  2. Initially Titanium used HTML for creating UI. Was basically a “webview” plus some native bindings.For Release 0.9 introduced native UI.For 1.8 we transitioned to V8 for our JS runtime. We saw a substantial increase in JS performance over Rhino.Rhino is still supported today, but our plans is to eventually deprecate it in favor of V8.
  3. Blue boxes -> activity stackRed boxes -> window stackHeavyweight:Launches a new activity when opened.Lightweight windows may be opened on top of it.Lightweight:Always opened on top of the current activity.Can co-exist with multiple windows on the same activity.Are basically just “views” placed into an activities content view layout.All windows are lightweight except when one of these properties is used during creation:FullscreennavBarHiddenModalwindowSoftInputModeWatch out for the back button. By default Android will finish the “top” activity in the stack.If you have multiple windows hosted by that activity, all of them will get closed.Break up your naivgation into “tasks” (ex: compose email, look up contact) and useHeavyweight windows for each task. Users expect back button to take them back to the previous task.DEMO
  4. Eventing: A common issue we see is the number of people listening to the ‘open’ event on a window to determine the height and width of a view inside the window. This is not correct since a layout pass is not guaranteed to have occurred when the event is fired. A better approach would be to listen to the ‘postlayout’ event instead. A post layout event occurs when native Android is done running through a layout pass, can happen multiple times.DEMO
  5. DEMO
  6. Target API levelSpecifies the version the app is “designed” to run on.Allows application to access features introduced in newer API levels (ex: 11 allows action bar and holo theme)Can still run on older versions, but must not use any newer features (detect os version).ThemesUsed on Android to give applications a consistent appearance.Android provides default themes such as Holo to provide greater cohesion between apps.Themes are extendable (style.parent) so you can mold them to get the style you want.Action Bar- Menu Item updated to expose some newer APIs.showAsAction: controls how the item appears in the bar (always, if space, never)actionView: custom view for the action itemNavigation TabsSame tab group API.Opt-in by setting target API level above 11.Replaces TabWidget style groups.Demo.
  7. MenuItem example.Left: bad exampleRight: Good practice. Use action items for more used items. Other menu items will overflow into drop down menu.