280 likes | 395 Views
Introduction to Android Development Using .NET and Mono. Greg Shackles Senior Application Developer MagazineRadar greg@gregshackles.com. About Me. Greg Shackles greg@gregshackles.com gregshackles.com Twitter: @ gshackles github.com/ gshackles. What We’ll Cover. What is Android?
E N D
Introduction to Android Development Using .NET and Mono Greg Shackles Senior Application Developer MagazineRadar greg@gregshackles.com
About Me • Greg Shackles • greg@gregshackles.com • gregshackles.com • Twitter: @gshackles • github.com/gshackles
What We’ll Cover • What is Android? • Android architecture • Application lifecycle • Mono / Mono for Android • Mono for Android API • Demos
What is Android? • Full stack • Open source • SDK provides tools and Java API • Applications typically written in Java • Purchased by Google in 2005 • v1.0 released in October 2008 • developer.android.com
Market Share (US) 33% 13%
Activities • Provides UI for one screen • Can start other activities • Hierarchy of views • Typically defined in XML
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()
Activity Lifecycle (Simplified) • Activity stack • Configuration changes cause activity restart • Activity has 3 basic states • Running • Paused • Stopped
Broadcast Receivers • No UI • Can start an activity • Receive/react to announcements • Apps can broadcast custom messages • Examples: low battery, phone call
Services • No UI, runs in background • Stays running when application loses focus • Can be accessed by many applications • Example: Music player
Content Providers • Enables applications to share data
Intents • Messages used to activate components • Launch an activity • Start or bind to a service • Broadcast a message to receivers • Implicit intents • Intent filters • Components register their capabilities • Example: launcher
Storage • Shared preferences • Internal storage • External storage (SD card) • Database (SQLite) • Remote
Want to write Android applications in .NET? With Mono for Android, you can!
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
What is Mono for Android? • Runs side by side with Dalvik • Wraps Java/Android API bindings • Commercial product • Visual Studio 2010 or MonoDevelop • www.mono-android.net
Pricing Free Trial: deploy only to emulator
Mono for Android Architecture • Android/Managed Callable Wrappers • JNI bridges to talk between Android and Mono
Mono for Android API • .NET events replace listener interfaces • Action replaces Runnable • Enumerations • Properties • Attributes and tooling generate configuration • OpenTK • Uses standard Android resource files
Java vs C# Java
Java vs C# Java C#