Mono for android

Preview:

Citation preview

Mono forAndroid

Developing Androidapplications using C# and

.NET

Willem Meints@wmeints

AgendaIntroduction

Android Framework

App model

Java vs. Mono

Bindings

Runtime

Developing Android applications using C# and .NET

Android

Open Source Mobile OS from Google

Hardware made by many

– HTC

– Samsung

Developing Android applications using C# and .NET

AndroidMany manufacturers means

– Many user interfaces

– Many hardware configurations

– Many active OS versions

Developing Android applications using C# and .NET

Android - Tools

Developing Android applications using C# and .NET

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

Cross Platform Mobile Development - Android

Android - Framework

Developing Android applications using C# and .NET

Linux Kernel

Libraries & Runtime

Application Framework

Applications

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

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

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

Android - Framework

Home

Contacts

Phone

Browser

<your app here>

Etc.

Developing Android applications using C# and .NET

Linux Kernel

Libraries & Runtime

Application Framework

Applications

App model - ComponentsApplications consist of several components

– Activities

– Content Providers

– Broadcast Receivers

– Services

Developing Android applications using C# and .NET

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

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

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

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

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

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

Cross Platform Mobile Development - 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

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

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

– You can generate them yourself from JAR files.

– Project type provided.

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

Some interesting thoughts

Developing Android applications using C# and .NET

UI UI UI

Business Logic

Device Device Device

Device abstraction layer

Cross Platform Mobile Development - Android

Questions?

Cross Platform Mobile Development - Android

Recommended