Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing mobile C# app to run on multiple platforms

We have an line-of-business app that runs on Windows Mobile. It's a Winforms app with a local SQL CE database and gets its data from a WCF Web Service running on the server.

Now customers are always asking "why don't you make a version for iPhone/iPad/Android/Phone 7 etc". My boss asked how hard this would be. My initial answer is very hard especially since I would probably be the only person doing the work. I don't have any experience outside my Visual Studio happy place.

Now I've come across MonoTouch and MonoDroid. They appears to offer an easy solution but I'm sure there are lots of issues. I doubt that I will be able to just compile my app for Android.

I'm inclined to suggest that it would be far too much work and that the only realistic solution is a mobile web site with several versions of each page for different screen resolutions. Unfortunately the existing app has a local database and is "sometimes connected" so that won't cut it.

Any suggestions and tips before I waste a huge amount of time?

Cheers
Mark

like image 516
Mark Evans Avatar asked Jan 20 '23 21:01

Mark Evans


1 Answers

I doubt that I will be able to just compile my app for Android

That is correct; you won't.

So, background: the design philosophy of MonoTouch and Mono for Android is to bring the "core" .NET and C# experience to iOS and Android while also exposing the underlying features of each specific platform. Whereas PhoneGap and Titanium abstract the underlying platform (for a "write-once, run-anywhere" vibe), MonoTouch and Mono for Android provide no platform abstractions and directly expose the underlying platform types and members.

The result is that MonoTouch programs use MonoTouch.UIKit.UIButton, which directly wraps the underlying CocoaTouch UIButton type.

Similarly, Mono for Android programs would use Android.App.Activity, which directly wraps the underlying Android android.app.Activity type.

Common across both platforms are the "core" framework namespaces and types which you find on .NET, .NET CF, Silverlight, Windows Phone 7, and Mono: System, System.Collections.Generic, System.Linq (yes, Linq-to-Objects), System.Xml.Linq (yes, Linq-to-XML), System.IO, etc., etc. For example, see the assemblies included in Mono for Android.

So, can you use your existing Windows Mobile app as-is on Android? No, because Mono for Android doesn't provide System.Windows.Forms.

However, it should be possible for you to refactor your existing code to follow a Model/View/Controller design pattern (or MVVM, or...), abstracting away the UI (View) so that you can replace it for various platforms, e.g. an iOS UI with MonoTouch, a WP7 UI with XAML, an Android UI with Mono for Android, an HTML UI with ASP.NET MVC, etc., etc. You won't get a "write once, run anywhere" experience, but you will be able to provide the user with native user interfaces which are consistent with their chosen platform.

For example, see the MIX11 Conference Apps, which utilize a common code base while providing platform-specific UIs for iOS, Android, and WP7.

like image 88
jonp Avatar answered Feb 01 '23 05:02

jonp