0

I am supporting a legacy Android app that was written in Xamarin. That Xamarin app will be replaced by a Cordova app. During a transition period I will need a solution that will support both. My high level thoughts are that after the user logs in to the app, I will send them to to what is applicable for them (legacy Xamarin or new Cordova). The app would effectively contain the code-base for both apps.

Is this sort of thing possible with Cordova - i.e. can I 'wrap' an exising Xamarin application inside of a Cordova one?

Thanks.

Nebu
  • 1,352
  • 1
  • 14
  • 21

2 Answers2

1

I've found this link about using phonegap on monotouch apps:

http://scott.blomqui.st/2012/08/embedding-cordova-phonegap-in-monotouch-apps/

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Looking at the link you cite, I believe to embed Cordova in his legacy Xamarin.Android app he would have to install the native libraries for Cordova. Doing some Googling it doesn't look like there's a Xamarin/C# version of these libraries, just Java. – Ben Bishop Mar 10 '15 at 13:51
  • @BenBishop, you can create Xamarin bindings to the JAR file: http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_(.jar)/ – SKall Mar 10 '15 at 15:10
  • I was aware of being able to create Bindings for Java JARs. I hesitated in bringing that up in that it is an advanced technique and I'm not sure how long that would take, but I digress. Good point. – Ben Bishop Mar 10 '15 at 15:24
1

The short answer is "no." Xamarin generates an executable binary, not a collection of HTML or JS files thus Cordova/PhoneGap cannot "wrap" it. With that said, you can probably do a couple of things:

1) Have your Cordova app open the original Xamarin.Android app via app url: Android Custom URL to open App like in iOS

2) In your legacy Xamarin.Android app create a WebView that loads the HTML/JS that your Cordova/PhoneGap would've. Basically, in a way, you'd be recreating the functionality of Cordova with Xamarin. http://developer.xamarin.com/recipes/android/controls/webview/call_csharp_from_javascript/ http://developer.xamarin.com/recipes/android/controls/webview/load_a_web_page/ http://developer.xamarin.com/recipes/android/controls/webview/load_local_content/

Community
  • 1
  • 1
Ben Bishop
  • 1,414
  • 9
  • 14
  • He's asking if you can "wrap" a Xamarin.Android app, which you cannot do. As someone mentions in the other answer if he wants to create bindings for the Cordova Android/Java SDK he could do that, but the Xamarin.Android app would still be the master app, not the Cordova app. – Ben Bishop Mar 10 '15 at 15:19
  • Also, I was just suggesting the app link as a way to accomplish this: "after the user logs in to the app, I will send them to to what is applicable for them (legacy Xamarin or new Cordova)" – Ben Bishop Mar 10 '15 at 15:20
  • Thanks @BenBishop and jcesarmobile. Certainly sums up my options. As a transitional state, I think the simplicity of embedding a WebView into the Xamarin.Android app is the way to go. In this stage there will be no real need for accessing the Cordova API's. Once the transition is out of the way, I think a target state of straight Cordova without any Xamarin is where I'll end up. By that time there might be a need to access those API's, but not right now. Again, thanks for your input. – Nebu Mar 10 '15 at 22:43