Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to port Android app to Windows Phone

Michele Capra
January 11, 2014

How to port Android app to Windows Phone

Android has gained a big market share in these days and right now many companies have apps published in Play Store, that's a fact. Recently Windows Phone has risen as a new player in the mobile market, especially in the low-end market segment where Android is the only option, and that's another fact. So now some companies are starting to asking themselves: what about porting my apps on Windows Phone 8? What does it involve? How far is Java from C#? Is Android Studio so different from Visual Studio for Windows Phone?
Based on my personal experience of porting a business application used by more than 40.000 workers across Europe i'll show you my journey from Android to Windows Phone.

Michele Capra

January 11, 2014
Tweet

More Decks by Michele Capra

Other Decks in Technology

Transcript

  1. #mceconf 11 Jan 2014 Mind the Gap! From Android to

    Windows Phone Michele Capra aka @piccoloaiutante #mce-mindthegap
  2. #mceconf 11 Jan 2014 What is this talk about? Little

    disclaimer: ‣ No, it’s not about Microsoft vs Google ‣ I’m pragmatic: I work on a Mac, I own Nexus 7 tablet, I own a Nokia Lumia 625. ‣ I’m a freelance, I develop app for Windows Phone 8 / Windows 8 #mce-mindthegap
  3. #mceconf 11 Jan 2014 What is this talk about ?

    ‣ My personal experience on porting a business App from Android to Windows Phone 8. #mce-mindthegap
  4. #mceconf 11 Jan 2014 Why I proposed this talk ?

    ‣ because I think that times are changing and Windows Phone 8 is growing its market share ‣ because I think that giving back my experience to the Community could help other developers #mce-mindthegap
  5. #mceconf 11 Jan 2014 Agenda ‣ The App ‣ Development

    tools ‣ Mockup ‣ Code and development (UI, component, languages) ‣ Integration with OS ‣ App lifecycle ‣ App publish and store #mce-mindthegap
  6. #mceconf 11 Jan 2014 The MDC client The case study:

    ‣ Mobile Data Collection (M.E.A.P .) ‣ create mobile application from a Web interface using a series of widgets ‣ deliver Apps to Android Tablet and Phone, iPad, iPhone, Blackberry, Windows Phone 8, Windows 8 RT/Pro ‣ developed by Gulliver, an italian company. #mce-mindthegap
  7. #mceconf 11 Jan 2014 Mdc architecture #mce-mindthegap App2 App1 App

    n Mdc Client App1 App2 Appn Data sync Activated client
  8. #mceconf 11 Jan 2014 MDC client ‣ Native clients (no

    Phone Gap) ‣ Proprietary protocol ‣ Occasionally connected ‣ Several different widget (picture, signature, position, textbox..) #mce-mindthegap
  9. #mceconf 11 Jan 2014 First big question To support Windows

    Phone 7 or not? We chose not to support it: ‣ Clear Microsoft intent to dismiss Windows Phone 7 ‣ Some of the components we needed were only for Windows Phone 8. Android support from 2.3 #mce-mindthegap
  10. #mceconf 11 Jan 2014 Windows Phone IDE ‣ Windows Phone

    Software Development Kit (free) ‣ Two separate SDK for Windows Phone 7.8 and Windows Phone 8 ‣ All the paid versions of Visual Studio support Windows Phone Development #mce-mindthegap
  11. #mceconf 11 Jan 2014 IDE Both support: ‣ Code completion

    ‣ Emulator
 ‣ Debugging ‣ Visual designer #mce-mindthegap
  12. #mceconf 11 Jan 2014 IDE Jet Brains solution could help

    you: ‣ Intellij Idea keyboard scheme and shortcut are available for Visual Studio through ReSharper plugin ‣ Code navigation, refactoring shortcuts… #mce-mindthegap
  13. #mceconf 11 Jan 2014 Mockup ‣ UI + Controls +

    Navigation - Logic ‣ Didn’t look at Android app code ‣ Just investigate ‣ Trying to figure out how to translate App flow from Android to Modern UI #mce-mindthegap
  14. #mceconf 11 Jan 2014 Component App capabilities: ‣ Take picture

    ‣ Read BarCode/QR Code ‣ Read NFC ‣ Get GPS coordinate ‣ Take signature ‣ Use web view ‣ Store data in a database ‣ Multi-language support #mce-mindthegap
  15. #mceconf 11 Jan 2014 Component ‣ Take picture (Intent →

    Request CameraTask) ‣ Read BarCode/QR Code (ZXing → ZXing.net) ‣ Read NFC (Intent → Microsoft library to do the job) ‣ Get gps coordinate ( LocationManager → GeoLocator) #mce-mindthegap
  16. #mceconf 11 Jan 2014 Component ‣ Take signature ( Canvas

    & Path → InkPresenter) ‣ Use web view (WebView → WebBrowser) ‣ Store data in a database (SQLite → SQLite) ‣ Multilanguage support (Xml file → Xml file) #mce-mindthegap
  17. #mceconf 11 Jan 2014 Java vs C# Academic answer for

    similarities: ‣ Statically strong typed ‣ Class-based, Object-oriented ‣ Semi-interpreted ‣ Garbage collection #mce-mindthegap
  18. #mceconf 11 Jan 2014 Java vs C# ‣ convert basic

    type ‣ change data structure: ‣ Vector<T> → List<T> ‣ HashTable<Integer,Integer> → Dictionary<int,int> ‣ change method name i.e: string.startWith() → string.StartsWith() ‣ StringTokenizer → String.split(string) #mce-mindthegap
  19. #mceconf 11 Jan 2014 Java vs C# Different pattern: ‣

    Android: Model-View-Presenter pattern but View and Presenter highly coupled. ‣ Windows Phone: Model-View-ViewModel pattern, Binding mechanism. #mce-mindthegap
  20. #mceconf 11 Jan 2014 XAML You can create visible UI

    elements in the declarative XAML markup, and then separate the UI definition from the run-time logic by using code-behind files, joined to the markup through partial class definitions. #mce-mindthegap
  21. #mceconf 11 Jan 2014 XML vs XAML Similarity: ‣ LinearLayout

    → StackPanel ‣ TextView, TextEdit → TextBlock,TextBox ‣ ScrollView → ScrollViewer ‣ Radio Group, RadioButton → RadioButton #mce-mindthegap
  22. #mceconf 11 Jan 2014 Values vs Xaml style Android Values:

    <color name=“white”>#FFFFFFFF</color> ! Windows Phone Xaml control style: <Color x:Key="white">#FFFFFFFF</Color> #mce-mindthegap
  23. #mceconf 11 Jan 2014 UI Difference: ‣ Xaml file needs

    a code-behind file and is compiled through partial mechanism. ‣ In Android you access UI elements using getElementById or similar. #mce-mindthegap
  24. #mceconf 11 Jan 2014 Integration with OS ‣ Make a

    phone call ‣ Send an email ‣ Open Map
 ‣ Navigate to a place ‣ Open link in browser ‣ Open pdf/office file #mce-mindthegap
  25. #mceconf 11 Jan 2014 Integration with OS In Android you

    do this by intent and activity. ! Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:0377778888")); startActivity(callIntent); #mce-mindthegap
  26. #mceconf 11 Jan 2014 Integration with OS In Windows Phone

    you use Tasks. ! PhoneCallTask phoneCallTask = new PhoneCallTask(); phoneCallTask.PhoneNumber = "2065550123"; phoneCallTask.Show(); #mce-mindthegap
  27. #mceconf 11 Jan 2014 Integration with OS Sending email in

    Android. ! Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{to}); startActivity(emailIntent); #mce-mindthegap
  28. #mceconf 11 Jan 2014 Integration with OS Sending email in

    Windows Phone. ! EmailComposeTask emailComposeTask = new EmailComposeTask(); emailComposeTask.To = “[email protected]”; emailComposeTask.Show(); #mce-mindthegap
  29. #mceconf 11 Jan 2014 Be careful From Microsoft docs: “It

    is possible, however, for an app to be tombstoned after the user navigates away. In this case, the app is not preserved in memory, but some information about the app is stored – most importantly for this topic, the State dictionary of the PhoneApplicationPage object is stored” #mce-mindthegap
  30. #mceconf 11 Jan 2014 Be careful ‣ Serialised and deserialise

    the app state that is not a part of the page ‣ Rebind all the dependencies ‣ Update UI value (i.e: something typed from user before tombstoning) #mce-mindthegap
  31. #mceconf 11 Jan 2014 App package ‣ Xap file which

    includes everything needed from the app. ‣ It’s almost like an apk file. ‣ You cannot install xap out of store. #mce-mindthegap
  32. #mceconf 11 Jan 2014 Google Play store ‣ Generate key

    pair and certificate and keystone
 ‣ Sign your app and verify signed app
 ‣ Upload and publish to Play store #mce-mindthegap
  33. #mceconf 11 Jan 2014 Windows Phone store Validation ‣ Package

    verification ! Certification ‣ Sign and encryption ! Publish ‣ Ready to be published #mce-mindthegap
  34. #mceconf 11 Jan 2014 Windows Store Test Kit The Windows

    Phone Windows Phone Store Test Kit (formerly named Marketplace Test Kit) provides a suite of automated and manual tests to help prepare your apps to be accepted in the Windows Phone Store the first time you submit them. #mce-mindthegap
  35. #mceconf 11 Jan 2014 Testing for tombstoning ‣ Before upload

    your xap to store simulate tombstoning and test your app manually. ‣ Tombstoning could be forced manually by Visual Studio. #mce-mindthegap
  36. #mceconf 11 Jan 2014 Recap ‣ The App ‣ Development

    tools ‣ Mockup ‣ Code and development (UI, Component, languages) ‣ Integration with OS ‣ App Lifecycle ‣ App publish and store #mce-mindthegap
  37. #mceconf 11 Jan 2014 Conclusions ‣ Java is not far

    from C# ‣ Build a mockup in order to explore new platform ‣ Keep an eye on app lifecycle ‣ Before starting, try to use a Windows Phone device as your primary device. #mce-mindthegap
  38. #mceconf 11 Jan 2014 References ‣ Comparison of C# and

    Java (Wikipedia) [http://en.wikipedia.org/wiki/ Comparison_of_C_Sharp_and_Java] ‣ Windows Phone SDK (Microsoft)[http://dev.windowsphone.com/en-us/ downloadsdk] #mce-mindthegap