September 30, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Porting from Android to Windows 8: The Real Story, Page 2

As my team ventured forward with porting our original Android app to Windows 8 Phone, we were surprised with not only how smoothly it went, but with how quickly we were able to get the job done. Many parts that required Java coding in the Android version didn't require any coding at all. Instead we were able to use the Visual Studio designer to lay out the controls, and quickly attach the code to them. The screenshot below shows the designer as we were laying out the controls on the main page.

the designer as we were laying out the controls on the main page

Creating the different pages was as easy as adding, clicking New and choosing Windows Phone Portrait Page. To navigate from the main page to the next page required a call to the NavigationService object's Navigate function, like so:

private void ApplicationBarIconButton_Click_2(object sender, EventArgs e) {

    NavigationService.Navigate(new Uri("/NewExpense.xaml", UriKind.Relative));

}
This, of course, was completely different from how we accomplished navigation through the Java code and Android. But given that we were able to quickly design our controls, and accomplish navigation with a single function call to Navigate, this was no problem whatsoever.

Meanwhile, as we were rebuilding our screens for the Windows Phone device, we were able to factor in a few changes after feedback from our employees regarding their usage with the Android version. There were a few usability issues that needed correcting. For example, the original one had a calendar that was accessible from the front screen; the employees really didn't find that feature particularly useful. Instead of searching for projects by date using the calendar feature they wanted easy access to the project list from the front screen, whereby they could search for the most recent couple of projects. We decided to replace the calendar with a sorted list of the projects.

The sorting would use the date of the most recent expense item. That way, if a project was ongoing for six months, and had an expense added just yesterday, for example, it would appear toward the top of the list, ahead of a project from last week that lasted only one day.

This meant that although we were porting the app, we were also doing a version upgrade. Originally the senior management balked at this idea. To non-technical folks, creating new features seemed more difficult and time consuming than just porting. In their eyes, we should first just port the existing product, get it working, and then think about adding new features. Fortunately we were able to convince them that development really doesn't work like that. Instead, this opportunity was the perfect time to add new features, because porting is never a matter of simply recompiling the code under a different platform. We were going from Java to C#, and we'd be rewriting large sections anyway.

This caused some concern among executives because now they were worried that porting wasn't so easy and it would take much longer than we thought. We came up with an easy solution: to convince them that it wouldn't be bad at all, we took a laptop into the conference room with them, launched Visual Studio, created a new Windows Phone project, dropped some controls on the page that looked basically like our expense tracking program, and then created a second page. The whole process took less than five minutes. They were stunned at how quickly we did that, and we made our case. They approved the project to move forward.

Other aspects of the system, such as the database, required some recoding, but again, it wasn't a huge problem. We used Microsoft's LINQ to SQL technology, which mean we could quickly do queries and save information to the database with only a few lines of code.

In the end, we created a beautiful app that worked perfectly on Windows Phone. The only part that really took a little more time (a couple extra days) was uploading the expense sheets to the internal server. The server was already set up to receive expense sheets from the original Android application. This worked by connecting to the server's internal IP address, and logging in with the credentials saved in the app. This again required some rewriting in C#; however, the API made it easy to simply initiate a TCP/IP connection and send the data up. That meant that we had to reconstruct the data structures in the exact same format used in the original Android application. Fortunately, we used JSON for that, and it was a snap to convert our structures to a JSON format and push it up. In the end, the server really didn't know or care whether it was the old Android app or the new Windows Phone app sending the data.

We also had a synchronization process running on the server that would handle repeat uploads. The server would go through the expense sheet, and look for any changes or updates. If there were changes, it would update the server-side data accordingly. Because this code lived on the server, we didn't need to rewrite any of it to handle the Windows Phone code.

It also meant we could roll our changes out gradually. Initially a couple members of the IT team switched to the Windows Phone version of the app, while everyone else continued using the Android app. Once we were happy with the results, we could start switching everybody else. And in the end, it all worked beautifully. Below are two screen shots of the final application.

the final application       the final application

Conclusion

Software developers enjoy programming, which is why they chose their profession. Sometimes, however, there are parts that aren't fun. In the end, most of us agreed that this was a fun project. Visual Studio was a joy to work with, and we were able to produce code quickly and easily. The Windows Phone was fun to use. Although we couldn't simply just recompile the code for Windows, rewriting it in C# allowed us to work in a few new features. And it didn't take long at all. Developing for Windows 8 Phone is a fast, smooth process, and the entire project was a big success.

This article was written by an independent writer, Jeff Cogswell. The article is, however, sponsored by Microsoft Corporation, which offers tools and resources for helping developers port from Android to Windows 8.


Tags: Android, port, Windows Phone 8



Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel