mono for android development

49
Mono for Android Development Monday Presentation by Codrin Dițu

Upload: thinslices

Post on 15-May-2015

1.329 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Mono for Android Development

Mono forAndroid Development

Monday Presentation by Codrin Dițu

Page 2: Mono for Android Development

Topics• Basics• Overview• Architecture • API• Demos• Myths• Benefits• Conclusions

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 3: Mono for Android Development

What is Mono?

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Mono?

Page 4: Mono for Android Development

Mono• is an

open source implementation of .NET Framework based on the ECMA standards

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 5: Mono for Android Development

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

Page 6: Mono for Android Development

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

Page 7: Mono for Android Development

What is Android?

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Android?

Page 8: Mono for Android Development

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

Page 9: Mono for Android Development

What is Android?• 1st release in October 2008, 5th this fall

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 10: Mono for Android Development

What is Android?

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 11: Mono for Android Development

What is Android?• full software stack, based on Linux 2.6

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 12: Mono for Android Development

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

Page 13: Mono for Android Development

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

Page 14: Mono for Android Development

Android architecture

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 15: Mono for Android Development

Android key components• Activities

single screen with an UI

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 16: Mono for Android Development

Android key components• Activities

single screen with an UI• Services

background running long operations

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 17: Mono for Android Development

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

Page 18: Mono for Android Development

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

Page 19: Mono for Android Development

What is Monodroid?

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Monodroid?

Page 20: Mono for Android Development

Mono for Android

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 21: Mono for Android Development

Mono for Android

CODRIN DIȚU

Commercial Productdevelop native Android apps using .NET

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 22: Mono for Android Development

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

Page 23: Mono for Android Development

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

Page 24: Mono for Android Development

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

Page 25: Mono for Android Development

Monodroid Architecture

CODRIN DIȚU

• Android/Managed Callable Wrappers(JNI bridges to do the talking)

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 26: Mono for Android Development

Monodroid API

CODRIN DIȚU

• .NET events replace listener interfaces

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 27: Mono for Android Development

Monodroid API

CODRIN DIȚU

• .NET events replace listener interfaces

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 28: Mono for Android Development

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)

Page 29: Mono for Android Development

Monodroid API

CODRIN DIȚU

• Action replaces Runnable

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 30: Mono for Android Development

Monodroid API

CODRIN DIȚU

• Enumerations• Properties• Attributes and tooling generate configuration• OpenTK• Uses standard Android resources

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 31: Mono for Android Development

Code

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

• MonoDevelop or Visual Studio 2010• tutorials on android.xamarin.com

•DEMOs

Page 32: Mono for Android Development

C# Code (Mono for android)

HelloWord native Android

Application

Page 33: Mono for Android Development

Java Code (the standard way)

HelloWord native Android

Application

Page 34: Mono for Android Development

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

Page 35: Mono for Android Development

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

Page 36: Mono for Android Development

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

Page 37: Mono for Android Development

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

Page 38: Mono for Android Development

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

Page 39: Mono for Android Development

Benefits• Benefit#1: cross platform (except GUI code)

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 40: Mono for Android Development

Benefits

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 41: Mono for Android Development

Benefits• Benefit#2: less code less bugs

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 42: Mono for Android Development

Benefits• Benefit#3: C#

o LINQ + org.xml.sax.XmlReadero Lamdas

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 43: Mono for Android Development

Drawbacks• Works Slow in Debugging

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 44: Mono for Android Development

Drawbacks• Android UI designer does not exist

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 45: Mono for Android Development

Drawbacks• It is a commercial product, so it costs!

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Page 46: Mono for Android Development

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

Page 47: Mono for Android Development

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

Page 48: Mono for Android Development

Thank you!Questions?

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits

Question!

Page 49: Mono for Android Development

CODRIN DIȚU

Basics

Overview

Architecture

API Demos

Myths Benefits