Mono forAndroid Development
Monday Presentation by Codrin Dițu
Topics• Basics• Overview• Architecture • API• Demos• Myths• Benefits• Conclusions
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Mono?
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Mono?
Mono• is an
open source implementation of .NET Framework based on the ECMA standards
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Mono• is an
open source implementation of .NET Framework based on the ECMA standards
• aims to be theleading choice for development of Linux applications
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Mono• is an
open source implementation of .NET Framework based on the ECMA standards
• aims to be theleading choice for development of Linux applications
• allows developers to easily create cross platform applications
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Android?
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Android?
What is Android?• world’s most popular mobile platform
(48,6 US market share, January 2012)
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Android?• 1st release in October 2008, 5th this fall
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Android?
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Android?• full software stack, based on Linux 2.6
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Android?• apps typically are written in Java
(SDK provides tools and Java API)
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Android?• apps typically are written in Java
(SDK provides tools and Java API)
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Android architecture
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Android key components• Activities
single screen with an UI
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Android key components• Activities
single screen with an UI• Services
background running long operations
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Android key components• Activities
single screen with an UI• Services
background running long operations• Content Providers
organized mechanism for data sharing
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Android key components• Activities
single screen with an UI• Services
background running long operations• Content Providers
organized mechanism for data sharing• Broadcast receivers
respond to system-wide announcements
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
What is Monodroid?
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Monodroid?
Mono for Android
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Mono for Android
CODRIN DIȚU
Commercial Productdevelop native Android apps using .NET
Basics
Overview
Architecture
API Demos
Myths Benefits
Mono for Android
CODRIN DIȚU
Commercial Productdevelop native Android apps using .NET
Mono Runtimeuse .NET standards LINQ, GC, lambas etc
Basics
Overview
Architecture
API Demos
Myths Benefits
Basics
Overview
Architecture
API Demos
Myths Benefits
Mono for Android
CODRIN DIȚU
Commercial Productdevelop native Android apps using .NET
Mono Runtimeuse .NET standards LINQ, GC, lambas etc
Linkerreduces app size by static analysis of your application
Basics
Overview
Architecture
API Demos
Myths Benefits
Mono for Android
CODRIN DIȚU
Complete
binding for Java / Android
API
Commercial Productdevelop native Android apps using .NET
Mono Runtimeuse .NET standards LINQ, GC, lambas etc
Linkerreduces app size by static analysis of your application
Monodroid Architecture
CODRIN DIȚU
• Android/Managed Callable Wrappers(JNI bridges to do the talking)
Basics
Overview
Architecture
API Demos
Myths Benefits
Monodroid API
CODRIN DIȚU
• .NET events replace listener interfaces
Basics
Overview
Architecture
API Demos
Myths Benefits
Monodroid API
CODRIN DIȚU
• .NET events replace listener interfaces
Basics
Overview
Architecture
API Demos
Myths Benefits
Monodroid API
CODRIN DIȚU
• Action replaces Runnable
Basics
Overview
Architecture
API Demos
Myths Benefits
public delegate void Action<in T>( T obj )
Example: Search(string query, Action<IEnumerable<Tweet>> callback)
Monodroid API
CODRIN DIȚU
• Action replaces Runnable
Basics
Overview
Architecture
API Demos
Myths Benefits
Monodroid API
CODRIN DIȚU
• Enumerations• Properties• Attributes and tooling generate configuration• OpenTK• Uses standard Android resources
Basics
Overview
Architecture
API Demos
Myths Benefits
Code
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
• MonoDevelop or Visual Studio 2010• tutorials on android.xamarin.com
•DEMOs
C# Code (Mono for android)
HelloWord native Android
Application
Java Code (the standard way)
HelloWord native Android
Application
Why bother with Mono after all?• Mith #1: the build apps are not native
Uses the exact same libraries as native apps
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Why bother with Mono after all?• Mith #1: the build apps are not native• Mith #2: it is for the lazy ones
You have to learn the native framework
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Why bother with Mono after all?• Mith #1: the build apps are not native• Mith #2: it is for the lazy ones• Mith #3: the build apps are slower
C# on Mono VMJava on Dalvik VM
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Why bother with Mono after all?• Mith #1: the build apps are not native• Mith #2: it is for the lazy ones• Mith #3: the build apps are slower• Mith #4: it is a hard approach
Java and C# are … similar, plus you have support from support from Xamarin (and google, stackoverflow, etc.)
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Why bother with Mono after all?• Mith #1: the build apps are not native• Mith #2: it is for the lazy ones• Mith #3: the build apps are slower• Mith #4: it is a hard approach• Mith #5: no reason
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Benefits• Benefit#1: cross platform (except GUI code)
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Benefits
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Benefits• Benefit#2: less code less bugs
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Benefits• Benefit#3: C#
o LINQ + org.xml.sax.XmlReadero Lamdas
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Drawbacks• Works Slow in Debugging
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Drawbacks• Android UI designer does not exist
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Drawbacks• It is a commercial product, so it costs!
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Conclusions• Monodroid is a good approach when
developing from scratch a cross-platform native mobile app
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
References• http://tnw.co/usmobilemarketshare2012• http://xamarin.com/monoforandroid• http://www.infoq.com/presentations/
Android-Development-Using-NET-and-Mono• http://www.slideshare.net/conceptdev/
crossplatform-mobile-dev-with-mono• http://www.slideshare.net/klmcmahon/
mono-for-android
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Thank you!Questions?
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits
Question!
CODRIN DIȚU
Basics
Overview
Architecture
API Demos
Myths Benefits