SlideShare a Scribd company logo
1 of 71
Download to read offline
WP7, iPhone,Android
Oh my!
Chris Hardy
Modern .NET day
Reading 23rd October 2010
Chris Hardy
• ASPInsider
• Mobile is my hobby
• http://twitter.com/chrisntr
http://greatfridays.com
http://emmawatson.com
http://dominion-funds.com
Covering...
• Windows Phone 7
• MonoTouch
• MonoDroid
• Code reuse
• Porting code
• Demos
Windows Phone 7
•Windows Only
•Visual Studio 2010 / Expression Blend 4
• Silverlight for Windows Phone...
• Great information for developers
MonoTouch
• Mac only
• MonoDevelop
•Apple’s Interface Builder
• Superset of Silverlight 3
• Good community around
MonoDroid(currently in preview form)
• Cross platform
•Visual Studio 2010 / MonoDevelop
• XML Files / DroidDraw
• Superset of Silverlight 3
• Early days
Windows Phone 7
• Metro
• Panorama/Pivot
• Launchers/Choosers
• Tombstoning
Metro
http://crocusgirl.wordpress.com/
Panorama/Pivot
Launchers/Choosers
• CameraCaptureTask
• EmailAddressChooserTask
• MarketplaceHubTask
• PhoneCallTask
• PhotoChooserTask
• SearchTask
• SmsComposeTask
Tombstoning
sort of multi-tasking
Demo
Twitter on Windows Phone 7
http://www.youtube.com/watch?v=CZcS5PYG9kw
Twitter on Windows Phone 7
What is MonoTouch?
What is Mono?
The .Net Framework
created by Miguel De Icaza
et al.
Miguel de Icaza
Mono’s JIT Engine
CIL
Mono
Memory
Apple Rules
• Contractual Requirements
• No interpreted code
• No shared libraries
• Kernel Limitations
• iPhone OS 2.0+ disables JIT
Mono’s AOT Engine
CIL
Mono
AOT Mono Runtime
ARM
Native
Code
MonoTouch Features
• mtouch
• MonoDevelop iPhone Add-In
• CocoaTouch.NET / monotouch.dll
• Full static AOT compiler
• Support for all your existing code
• Reflection
• Generics
• LINQ
• Anonymous Methods
• Lambda’s etc...
MonoTouch’s APIs
The Bindings
• MonoTouch namespace
• MonoTouch.Foo namespace
• Maps to CocoaTouch’s Foo Framework
• 1:1 Mapping of classes.
• MonoTouch.UIKit.UILabel
• CocoaTouch’s UIKit framework, UILabel
class
Strong Types
• Objective-C
• Arrays are weakly typed:
• NSArray return values.
• MonoTouch has strong types
• UIView[] Subviews { get; }
• vs
• NSArray *subviews;
• Intellisense - explore the API...
Garbage Collection
• Automatic:
• Mono’s GC will collect objects on demand
• Deterministic:
• Use when you need control.
• Every object in MonoTouch implements IDisposable
using (var image = UIImage.FromFile(“foo.png”)){
surface.DrawImage(image, 20, 20);
}
Linker
and the application size...
Linking Assemblies
App-store MonoTouch
Minimum App Size
~6MB
Integration
• Tight integration between MD and IB
• IB produces XIBs with MD parses
• Automatic class generation in MD
• Generates partial classes for all types,
outlets and actions defined in Interface
Builder
MonoTouch Events
• Supports Objective-C pattern:
webView.Delegate = new
MyWebViewDelegate();
• C# style events as well:
webView.PageLoaded += delegate {
HideSpinningWheel();
}
Debugging
• Console.WriteLine(“Debugging inside of
MonoTouch”);
• printf(“I made it to this line!n”)
Debugger
• MonoTouch debugger leverages Mono’s
new Soft-Debugger
• Supports the Simulator
• Supports the Device...
• even over WiFi
Professional iPhone
Programming with
MonoTouch and .NET/
C#
Wallace B. McClure
Rory Blyth
Martin Bowling
Craig Dunn
and me... Chris Hardy
Out Now!
Demo
Twitter on iPhone with MonoTouch
Twitter on iPhone with MonoTouch
Will probably do a video in the future :)
What is MonoDroid?
What is MonoDroid?
What is MonoDroid?
C# on Android
What is MonoDroid?
A commercial product
What is MonoDroid?
Preview release
Not Alpha
Not Beta
What is MonoDroid?
Cross-platform
What is MonoDroid?
Sign-up for preview
access
http://go-mono.com/monodroid/
Demo
Twitter on Android with MonoDroid
Twitter on Android with MonoDroid
http://www.youtube.com/watch?v=TKXgugOj56I
Application Stores
Windows Phone 7
$99 PerYear
iPhone
$99 PerYear
Android
$25 Registration
Code reuse
Code reuse
Json.Net
FlickrNet
XNATouch
Rebuild your libraries
• Can’t just use any DLL
• Re-compile for each lib
• Each framework has its own class library
Not an abstraction!
Not an abstraction!
• Platform specific APIs
• Platform specific look and feel
Mono for WP7?
Mono for WP7?
• Look at Mono code and copy over!
• IQueryable support in WP7
• More later...
Porting over
Hanselminutes
Porting over
Hanselminutes
hanselminutesiphone.codeplex.com
Porting over
Hanselminutes
• Make sure your business logic is separate
• Use actions for returning results
Getting XML
Persisting the XML
Isolated Storage
vs
File Storage
Storing data
void SaveLocal(string data)
{
#if (MonoTouch || MonoDroid)
File.WriteAllText(_localPath, data);
#elif WINDOWS_PHONE
using (var appStorage =
IsolatedStorageFile.GetUserStoreForApplication())
{
var file = appStorage.OpenFile(_localPath, FileMode.Create);
FileExtension.WriteAllText(file, data);
}
#endif
}
Storing data
void SaveLocal(string data)
{
#if (MonoTouch || MonoDroid)
File.WriteAllText(_localPath, data);
#elif WINDOWS_PHONE
using (var appStorage =
IsolatedStorageFile.GetUserStoreForApplication())
{
var file = appStorage.OpenFile(_localPath, FileMode.Create);
FileExtension.WriteAllText(file, data);
}
#endif
}
No File.WriteAllText?
No problem!
Implementing
File.WriteAllText
public static void WriteAllText(IsolatedStorageFileStream fileStream, string data)
{
using (StreamWriter sw = new StreamWriter(fileStream))
{
sw.Write(data);
sw.Close();
}
}
public static void WriteAllText(string path, string contents)
{
WriteAllText(path, contents, Encoding.UTF8);
}
public static void WriteAllText(string path, string contents, Encoding encoding)
{
using (StreamWriter sw = new StreamWriter(path, false, encoding))
{
sw.Write(contents);
}
}
Limited WebClient calls
Downloading a file -
MonoTouch
_webClient = new WebClient ();
_webClient.DownloadFileCompleted += (sender, e) =>
{
	

 _fileDownloaded = true;
	

 if (_downloadCompletedSuccessfully) {
	

 	

 File.Copy (_show.PartialAudioPath, _show.OfflineAudioPath);
	

 }
	

 UIHelper.StopInternetActivity ();
};
_webClient.DownloadProgressChanged +=
HandleClientDownloadProgressChanged;
_webClient.DownloadFileAsync (new Uri (_show.Url), _show.PartialAudioPath);
Downloading a file WP7
var client = new WebClient();
client.DownloadProgressChanged += (s, e) =>
{
progressBar1.Value = e.ProgressPercentage / 100;
};
client.OpenReadCompleted += (s, e) =>
{
using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
using (var fs = new IsolatedStorageFileStream(CurrentShow.OfflineAudioPath,
FileMode.Create, isoStore))
{
int bytesRead;
byte[] bytes = new byte[1024 * 1024 * 1]; // 1meg
while ((bytesRead = e.Result.Read(bytes, 0, bytes.Length)) != 0)
{
fs.Write(bytes, 0, bytesRead);
}
_fileDownloaded = true;
fs.Flush();
}
};
client.OpenReadAsync(new Uri(CurrentShow.Url, UriKind.Absolute));
Porting your code
• MOMA for Mobile?
Conclusions
Thanks! Any questions?
twitter.com/chrisntr
chrisntr@gmail.com

More Related Content

Similar to WP7, Droid, iPhone, Oh my!

Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Bala Subra
 
Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1
drudolph11
 
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapBuilding Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Nick Landry
 

Similar to WP7, Droid, iPhone, Oh my! (20)

Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
Mobile Development Architecture Ppt with Slides, Book Notes on using Web Silv...
 
Italian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch SessionItalian Alt.Net Conference MonoTouch Session
Italian Alt.Net Conference MonoTouch Session
 
C# on the iPhone with MonoTouch Glasgow
C# on the iPhone with MonoTouch GlasgowC# on the iPhone with MonoTouch Glasgow
C# on the iPhone with MonoTouch Glasgow
 
Developing Windows Phone 8 apps using PhoneGap
Developing Windows Phone 8 apps using PhoneGapDeveloping Windows Phone 8 apps using PhoneGap
Developing Windows Phone 8 apps using PhoneGap
 
Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...
Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...
Firefox OS Apps & APIs - Dutch Mobile Conference / Serbia & Montenegro App da...
 
Learning C# iPad Programming
Learning C# iPad ProgrammingLearning C# iPad Programming
Learning C# iPad Programming
 
Building Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst PlatformBuilding Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst Platform
 
DDive- Giuseppe Grasso - mobile su Lotus
DDive- Giuseppe Grasso - mobile su LotusDDive- Giuseppe Grasso - mobile su Lotus
DDive- Giuseppe Grasso - mobile su Lotus
 
Outsmarting SmartPhones
Outsmarting SmartPhonesOutsmarting SmartPhones
Outsmarting SmartPhones
 
C# On The iPhone with MonoTouch at DDD8
C# On The iPhone with MonoTouch at DDD8C# On The iPhone with MonoTouch at DDD8
C# On The iPhone with MonoTouch at DDD8
 
Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Palm Developer Day PhoneGap
Palm Developer Day PhoneGap
 
DjangoSki
DjangoSkiDjangoSki
DjangoSki
 
Cross-Platform Development
Cross-Platform DevelopmentCross-Platform Development
Cross-Platform Development
 
iOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyiOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET Guy
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
PhoneGap Talk @ Sencha Con 2010
PhoneGap Talk @ Sencha Con 2010PhoneGap Talk @ Sencha Con 2010
PhoneGap Talk @ Sencha Con 2010
 
Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1Windows 8 DevUnleashed - Session 1
Windows 8 DevUnleashed - Session 1
 
Cross-Platform Mobile Development using Visual Studio and Xamarin
Cross-Platform Mobile Development using Visual Studio and XamarinCross-Platform Mobile Development using Visual Studio and Xamarin
Cross-Platform Mobile Development using Visual Studio and Xamarin
 
DDive11 - Mobile Development For Domino
DDive11 - Mobile Development For DominoDDive11 - Mobile Development For Domino
DDive11 - Mobile Development For Domino
 
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapBuilding Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

WP7, Droid, iPhone, Oh my!