270 likes | 432 Views
Introduction to Android Development Using .NET and MonoDroid. Greg Shackles Senior Application Developer MagazineRadar greg@gregshackles.com. Fairfield / Westchester Code Camp 4 (2010). We thank the following companies for their gracious sponsorship:. Platinum. Gold. Silver.
E N D
Introduction to Android Development Using .NET and MonoDroid Greg Shackles Senior Application Developer MagazineRadar greg@gregshackles.com
Fairfield / Westchester Code Camp 4 (2010) We thank the following companies for their gracious sponsorship: Platinum Gold Silver Other Material Contributions Came From:
About Me • Greg Shackles • greg@gregshackles.com • www.gregshackles.com • Twitter: @gshackles Fairfield / Westchester Code Camp 4 (2010)
What We’ll Cover • What is Android? • Android architecture • Application lifecycle • Mono/MonoDroid • Demos Fairfield / Westchester Code Camp 4 (2010)
What is Android? • Full stack • Open source • SDK provides tools and Java API • All applications written in Java • Purchased by Google in 2005 • v1.0 released in October 2008 Fairfield / Westchester Code Camp 4 (2010)
Market Share (US) 21.4% 13% Source: comScore Fairfield / Westchester Code Camp 4 (2010)
Architecture Fairfield / Westchester Code Camp 4 (2010)
Architecture Fairfield / Westchester Code Camp 4 (2010)
Architecture Fairfield / Westchester Code Camp 4 (2010)
Architecture Fairfield / Westchester Code Camp 4 (2010)
Architecture Fairfield / Westchester Code Camp 4 (2010)
Component Types Fairfield / Westchester Code Camp 4 (2010)
Activities • Provides UI for one screen • Can start other activities • Hierarchy of views Fairfield / Westchester Code Camp 4 (2010)
Activity Lifecycle Activity Starts onRestart() onStart() onResume() onCreate() User navigates back to the activity Activity is running User navigates back to the activity User navigates back to the activity Another activity is loaded Process killed Other apps need memory onPause() This activity is no longer visible onStop() Activity is shut down onDestroy() Fairfield / Westchester Code Camp 4 (2010)
Activity Lifecycle (Simplified) • Activity stack • Activity has 3 basic states • Running • Paused • Stopped • Configuration changes cause activity restart Fairfield / Westchester Code Camp 4 (2010)
Broadcast Receivers • No UI • Can start an activity • Receive/react to announcements • Examples: low battery, phone call Fairfield / Westchester Code Camp 4 (2010)
Services • No UI, runs in background • Stays running when application loses focus • Can be accessed by many applications • Example: music player Fairfield / Westchester Code Camp 4 (2010)
Content Providers • Enables applications to share data Fairfield / Westchester Code Camp 4 (2010)
Intents • Messages used to activate components • Launch an activity • Start or bind to a service • Broadcast a message to receivers • Implicit intents • Intent filters • Example: launcher Fairfield / Westchester Code Camp 4 (2010)
Storage • Shared preferences • Internal storage • External storage (SD card) • Database (SQLite) • Remote Fairfield / Westchester Code Camp 4 (2010)
Wouldn’t it be awesome to write Android applications in .NET? Fairfield / Westchester Code Camp 4 (2010)
Wouldn’t it be awesome to write Android applications in .NET? With MonoDroid, you can! Fairfield / Westchester Code Camp 4 (2010)
What is Mono? • Implementation of the .NET CLR • Open source • Cross platform • Supports most of .NET 4.0 • Missing WPF, Entity Framework, WF, some WCF Fairfield / Westchester Code Camp 4 (2010)
What is MonoDroid? • Runs side by side with Dalvik • Wraps Java/Android API bindings • Exposes them in a .NET friendly way • Commercial product • Currently in private beta • Visual Studio 2010 or MonoDevelop Fairfield / Westchester Code Camp 4 (2010)
MonoDroid Architecture • Android/Managed Callable Wrappers • JNI bridges to talk between Android and Mono • Shared runtime Fairfield / Westchester Code Camp 4 (2010)
Questions? Fairfield / Westchester Code Camp 4 (2010)
Useful Links • http://monodroid.net/ • http://mono-project.com • http://developer.android.com • http://source.android.com/ Fairfield / Westchester Code Camp 4 (2010)