Convert My MVC4 Web application to Android?

android, asp.net-mvc-4, xamarin.android

Solution

You won't be able to rip out your Models and Controllers directly from your MVC4 app and stuff it into an Xamarin.Android Application. However you will be able to reuse some of it. Especially the models.

At work I ported a Silverlight app to WP7/Android/iOS apps where a lot of the logic fetching data from servers, models and more were directly copy/pasted. However all the Views and logic for the Views had to be written from scratch as View Ports are different on a Computer monitor and a mobile device, and general UI is very different.

Also using the MVVM pattern helps separating the UI from the Model making the apps more testable and allows more code sharing. For this I use MvvmCross. There is also an MVC alternative called MonoCross. Both are free as in beer and as in speech. Both of these are for Xamarin.Android.

If you are only going to make an Android application and not going to be making it for other platforms as well and don't want to pay the price of the Xamarin products you should be able to make it in native Android. I don't see why this is possible. However you really need to find out what it is you want.

What does your Web App do? My guess is that it somehow manipulates some data in a database. So you would need to alter your Web App to expose that database in some kind of Web Service, maybe RESTful or otherwise. You will need to layout your Android application such that the Views of the Web App you have fits into the smaller view ports of the mobile devices. A good too for this is to sketch your Android app out on paper and make arrows and annotations. You probably already know the model of your code in the Web App, it would be similar in your Android app. So get started coding the Views and then wire them up to the Web Service.

If you have read this far you might notice my answer is very vague. This is because your question is very vague.

Problem

I have a web application developed on .NET Framework using MVC4. So now I need to create a Android Application for it. - Do I have to convert my entire C# code to Java (The code in controllers in my MVC app)? - Will it be better if I use Xamarin? - Can I just create new Views for my application as I have controllers and Models? How do I approach this?

Original source