mono for android

27
Mono for Android Developing Android applications using C# and .NET Willem Meints @wmeints

Upload: willem-meints

Post on 05-Jul-2015

428 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Mono for android

Mono forAndroid

Developing Androidapplications using C# and

.NET

Willem Meints@wmeints

Page 2: Mono for android

AgendaIntroduction

Android Framework

App model

Java vs. Mono

Bindings

Runtime

Developing Android applications using C# and .NET

Page 3: Mono for android

Android

Open Source Mobile OS from Google

Hardware made by many

– HTC

– Samsung

Developing Android applications using C# and .NET

Page 4: Mono for android

AndroidMany manufacturers means

– Many user interfaces

– Many hardware configurations

– Many active OS versions

Developing Android applications using C# and .NET

Page 5: Mono for android

Android - Tools

Developing Android applications using C# and .NET

Page 6: Mono for android

Introducing Mono for AndroidMono for Android is

– .NET Runtime for Android

– Bindings to Android API’s

– Visual Studio 2010 plugin

• MonoDevelop also possible

Uses all the Android SDK tools under the hood(emulator, adb, etc.)

Developing Android applications using C# and .NET

Page 7: Mono for android

Cross Platform Mobile Development - Android

Page 8: Mono for android

Android - Framework

Developing Android applications using C# and .NET

Linux Kernel

Libraries & Runtime

Application Framework

Applications

Page 9: Mono for android

Android - Framework

Linux Kernel

Drivers for

– Display

– Camera

– WiFi

– Audio

– Keypad

– Etc.

Developing Android applications using C# and .NET

Linux Kernel

Libraries & Runtime

Application Framework

Applications

Page 10: Mono for android

Android - Framework

Dalvik VM

Libraries for

– Media

– SQLite

– SSL

– OpenGL

– WebKit

– Etc.

Developing Android applications using C# and .NET

Linux Kernel

Libraries & Runtime

Application Framework

Applications

Page 11: Mono for android

Android - Framework

Activity Manager

Window Manager

Content Providers

Package Manager

Location Manager

Notification Manager

Telephony Manager

Developing Android applications using C# and .NET

Linux Kernel

Libraries & Runtime

Applications

Application Framework

Page 12: Mono for android

Android - Framework

Home

Contacts

Phone

Browser

<your app here>

Etc.

Developing Android applications using C# and .NET

Linux Kernel

Libraries & Runtime

Application Framework

Applications

Page 13: Mono for android

App model - ComponentsApplications consist of several components

– Activities

– Content Providers

– Broadcast Receivers

– Services

Developing Android applications using C# and .NET

Page 14: Mono for android

App model - Activity lifecycleActivity

Launched

onCreate()

onStart()

onResume()

onPause()

onStop()

onDestroy()

onRestart()

Activity shutdown

Activity running

User navigates to

the activity

Apps with higher

priority need

memory

User returns to

the activity

User navigates to

the activity

Another activity comes into the

foregroundApp process

killed

The activity is no longer visible

The activity is finishing or being

destroyed by the system

Initializelayout here

Save state here

Restorestate here

Page 15: Mono for android

App model - Intents

Developing Android applications using C# and .NET

Activity Activity

View View

Intent

Intent

Broadcast Receiver

Service

Content Provider

Intent

Inten

t

Inten

t

Inte

nt

Page 16: Mono for android

App model - IntentsIntents are messages routed through the OS

Intents are powerful. They allow:

– Components of one application to be used byanother

– Allows applications to replace core OS functionality

Developing Android applications using C# and .NET

Page 17: Mono for android

App modelThe app model for Mono for Android is the same as for regular Android apps.

The behind the scenes however…

Cross Platform Mobile Development - Android

Page 18: Mono for android

Mono for Android architecture

Developing Android applications using C# and .NET

Linux Kernel

Mono (.NET Runtime) Dalvik (Java Runtime)

.NET APIsAndroidBindings

Android.*

Java.*MCW

ACW

Page 19: Mono for android

Java vs. Mono - Callable WrappersMono Callable Wrappers (MCW)

– Mono Java

– Uses JNI ( Java Native Interface )

Android Callable Wrappers (ACW)

– Java Mono

– Uses Mono runtime components

Developing Android applications using C# and .NET

Page 20: Mono for android

Cross Platform Mobile Development - Android

Page 21: Mono for android

Mono for Android - Bindings99,9% of the Android API is bound to .NET

– There’s always a few minor details that work different or couldn’t be converted (yet!)

Most of the Java API is bound as well.

– These are redundant, but necessary to make some of the Android stuff work.

Developing Android applications using C# and .NET

Page 22: Mono for android

Mono for Android - RuntimeAndroid apps are optimized using the linker

– Users don’t need to install the runtime on their phone. It is included in the package.

Please note:

– While running in debug, the app is not linked unless you specify that it must be linked

– Linking in debug has effect on the debugging capabilities

Developing Android applications using C# and .NET

Page 23: Mono for android

Mono for Android - RuntimeNeed a library that isn’t bound yet?

– You can generate them yourself from JAR files.

– Project type provided.

Page 24: Mono for android

Some interesting thoughtsMono for Android is C# for the Android platform, which means

– You can reuse a lot of code in Windows Phone and Monotouch apps

– If you split your code correctly of course.

Developing Android applications using C# and .NET

Page 25: Mono for android

Some interesting thoughts

Developing Android applications using C# and .NET

UI UI UI

Business Logic

Device Device Device

Device abstraction layer

Page 26: Mono for android

Cross Platform Mobile Development - Android

Page 27: Mono for android

Questions?

Cross Platform Mobile Development - Android