Cross-platform Mobile Development
Upcoming SlideShare
Loading in...5
×
 

Cross-platform Mobile Development

on

  • 30,798 views

Learn about cross-platform approaches to developing native applications using C# and .NET for iOS, Android and Windows Phone 7.

Learn about cross-platform approaches to developing native applications using C# and .NET for iOS, Android and Windows Phone 7.

Statistics

Views

Total Views
30,798
Views on SlideShare
6,888
Embed Views
23,910

Actions

Likes
14
Downloads
388
Comments
0

14 Embeds 23,910

http://blog.xamarin.com 17191
http://www.go-mono.com 5665
http://go-mono.com 849
http://www.go-mono.org 99
http://go-mono.org 69
http://translate.googleusercontent.com 19
http://webcache-exp-test.googleusercontent.com 4
http://go-mono.net 4
http://blog.huihoo.com 3
http://www.techgig.com 3
http://webcache.googleusercontent.com 1
http://www.hanrss.com 1
http://localhost 1
https://twitter.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Cross-platform Mobile Development Cross-platform Mobile Development Presentation Transcript

  • Xamarin Seminar 19th April 2012 Copyright 2012 © Xamarin Inc. All rights reserved
  • AgendaCross-Platform Mobile Development Greg Shackles Senior Software Engineer OLO Online Ordering greg@gregshackles.com gregshackles.com @gshackles github.com/gshackles Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • IntroductionThis session will discuss how to use C# to developiOS, Android and Windows Phone applications.We’ll cover: •Why use C#? •Code sharing techniques and patterns •Useful libraries Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Native Platform Languages Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Write Once, Run Anywhere? != != Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • C# to the Rescue! Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Benefits•C# and .NET are mature and powerful•Skill reuse on all platforms•Apps are still completely native•Code can be reused across platforms (even non-mobile platforms!) Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Architecture Mono#for# UI# Silverlight# MonoTouch# Android# C## Business#Logic#Run)me# .NET# Mono#Pla/orm# WP7# iOS# Android# Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • What Code Can Be Shared?•Most non-UI or platform code•Core application logic•Entities•LINQ (objects, XML)•Network access (System.Net) Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Requirements•MonoTouch •Mac OS X •MonoDevelop•Mono for Android •Mac OS X or Windows •MonoDevelop or Visual Studio 2010•Windows Phone •Windows •Visual Studio 2010 Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • File Linking•All profiles are not created equal•Single copy of file•Compile-time verification•Project Linker extension for VS2010 http://msdn.microsoft.com/en-us/library/ff648745 Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Abstraction•Separate common logic from UI•Interfaces, base classes, etc.public interface IContactManager{ IList<Person> GetContacts();}public class AndroidContactManager : IContactManager{ public IList<Person> GetContacts() { return null; }} Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Library: Xamarin.Mobile•Abstraction layer over platform APIs •Contacts •Geolocation •Camera •... http://xamarin.com/mobileapi Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Observer Pattern•Decouple UI from business logic•Business layer can publish updates•UI layer subscribes to updatespublic EventHandler<EventArgs> MessageReceived;MessageReceived += (sender, args) =>{ Console.WriteLine("Message received");}; Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Library: TinyMessenger•Event aggregator/messenger•Publish/subscribe•Single file•Supports iOS, Android, Windows Phone https://github.com/grumpydev/TinyMessenger Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Partial Classes and Methodspublic partial class MyClass{ // partial methods are private, and must return void partial void Foo(); public void Bar() { Foo(); }}public partial class MyClass{ partial void Foo() { Console.WriteLine("Foo"); }} Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Conditional Compilation#if __ANDROID__ Console.Write(“Only on Android”);#elif WINDOWS_PHONE Console.Write(“Only on Windows Phone”);#else Console.Write(“Everything else”);#endif Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Conditional Compilation•MonoTouch •No default symbols•Mono for Android •Windows Phone •__ANDROID__ •WINDOWS_PHONE •__ANDROID_1__ •SILVERLIGHT •__ANDROID_2__ •... Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • File Access•Direct file access •System.IO •Works on iOS and Android •Not supported by Windows Phone •Paths are different on iOS and AndroidFile.WriteAllText( Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Writing directly to a file"); Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • File Access•Isolated Storage •Works on iOS, Android, and Windows Phone •Higher level API •Don’t need to worry about file pathsusing (var store = IsolatedStorageFile.GetUserStoreForApplication())using (var writer = store.OpenFile("MyFile", FileMode.Create)){ // write to the file} Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Database Access•iOS and Android •SQLite •Native APIs or ADO.NET•Windows Phone •SQL Server CE •LINQ to SQL Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Library: C#-SQLite•C# port of SQLite database•File based•Useful for Windows Phone, Silverlight http://code.google.com/p/csharp-sqlite Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Library: sqlite-net•Layer over SQLite database•Strongly-typed queries•Single file•Supports iOS, Android, Windows Phone http://code.google.com/p/sqlite-net Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Library: TinyIoC•Inversion of Control container•Single file•Supports iOS, Android, Windows Phone https://github.com/grumpydev/TinyIoC Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Library: MonoCross•Cross-platform MVC framework•Shared models and controllers•Views specific to platforms•Supports iOS, Android, Windows Phone•Sits atop MonoTouch, Mono for Android http://code.google.com/p/monocross/ Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • More LinksMWC 2012 Apphttps://github.com/xamarin/mobile-samples/tree/master/MWCNYC Code Camp 6 Apphttps://github.com/gshackles/NycCodeCamp6Mobile Development in C#http://amzn.com/1449320236 Xamarin Copyright 2012 © Xamarin Inc. All rights reserved
  • Xamarin Seminar Please give us your feedback http://bit.ly/xamfeedback Follow us on Twitter @XamarinHQ 19th April 2012 Copyright 2012 © Xamarin Inc. All rights reserved