18th Sep

Developing on Windows 8.1 platform through the eyes of an Android developer

Friday, September 18, 2015 - 13:33
3

After more than 3 years of Android development, 9 months ago I started to develop on Windows 8.1 / Windows Phone 8.1platform. So (almost) sufficient experience behind me, the time is here for comparison based on my solid knowledge of Android and two implemented projects on Windows.

On the ring

Against the over-excitement: In the end will be a close scoring victory. Or defeat. The truth is I will not announce a winner. So now, the match begins:

Round 1: Development environment

I developed Android projects using the Eclipse SDK for Android, while I am using Visual Studio 2013 for Windows development. They both have flaws. The Eclipse (although this is more of the Android SDK's fault) often slows down, and a frequent restarts are required. However, VS is difficult to use, because it is more complicated to navigate through the project code, the keyboard shortcuts almost without exception is double keys, etc. I could say that it's just a matter of time to get used with it (I already use Eclipse for 14 years), but after nine months VS use it has not changed much in my opinion.

Overall, this round ended with: 1:1.

Round 2: Devices

Both platforms have many different devices. First, the screen resolution is important from a development point of view. This shows a big enough variety for both platforms. The UI development therefore requires a great deal of attention. There are completely different solutions, and none of the approaches are clearly better than the other.
Another important aspect is the performance. This can range widely between both platforms. However, in Android low performance devices can be excluded by setting the minimum supported os version, on Windows no such solution exists so the application must be runnable on all devices. On Windows performance optimization is a very important topic.
Major advantage of the Windows platform is the emulator. In practice, an application can be developed without any real devices. The emulator is using the developers machine CPU, so that the application may be significantly slower on a low performance real device.

Overall, this round goes to Windows 2-1.

Round 3: Testing

In order to be able to test the application a real device using Windows a little more circumstantial. On tablets a remote debugger has to be installed on the device. On Windows Phone the developer must register the device with developer ID. Because it has to be done only once it causes a small discomfort only at the beginning.
The debugging process (not surprisingly) is not very different on the two platforms. Unfortunately, Windows provides only a very limited debug info.

All in all, this round goes to Android 1: 0.

Round 4: Help and documentation

For effective development booth good offline and online documentation are essential. In the quality of the documentation there is not much difference between the two platforms, the only problem is that in Windows it is very difficult to find the correct documentation for a specific Windows or API version. Finding usable Windows- examples on the net for any topic is also very problematic. The main reason is that while different versions of Android build on each other, they rarely have an API change (this otherwise well-documented), which causes serious extra work for the developers, while in the case of Windows virtually every new platform (WP7, WP8, WP8.1 Silverlight, WinRT, Windows10) is significantly different from the previous one and incompatible with the earlier solutions. The unfortunate (though not inevitable) consequences is that in case of a search you cannot know that the founded description or example are related to which OS/API version. If you find a suitable example for the platform even then it may not work, because it could be faulty. The biggest problem is that even in the published msdn.microsoft.com codes often contains errors.

This round is in favor of Android 2-0 although more points should be taken away from Windows.

Round 5: Development

The source code is structured similarly in both platforms. An XML-based layout description (xml in Android, XAML in Windows), and data / logical layers (for android java, C# for Windows).
The structure of the two languages are similar, with a little difference in the linguistic structure. The transition from Java to C# wasn't a hard work. Although there is still more to learn, but to solve the project tasks the required abilities can be mastered easily. There were code blocks (especially background functions, such as data synchronization) in which a large part of the source code was operatively transferable from Android to Windows.
The most significant difference is the way of UI implementation.
I won’t compare the useable items here, because almost everything has a pair even if it used slightly differently.
The biggest difference is in the data binding. While in Android all the data had to be written into the layout in java code, while in Windows, using the binding made it much easier to achieve.
Let's see the difference how a complex UI element is used. The example below shows a list of displayed data.

And let's see what it takes to make it look like this:

On Android like this:

List descriptor xml

  1. <ListView
  2.             android:id="@+id/postofficeslist"
  3.             android:layout_width="match_parent"
  4.             android:layout_height="match_parent"
  5.             android:paddingBottom="5dp" >
  6.         </ListView>

List item descriptor xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="<a href="http://schemas.android.com/apk/res/android"
  3. ">http://schemas.android.com/apk/res/android"
  4. </a>    android:layout_width="match_parent"
  5.     android:layout_height="match_parent"
  6.     android:orientation="horizontal"
  7.     android:paddingBottom="8dp"
  8.     android:descendantFocusability="blocksDescendants"
  9.     android:paddingTop="8dp" >
  10.  
  11.     <ImageView
  12.         android:id="@+id/post_offices_list_item_type_image"
  13.         android:layout_width="0dp"
  14.         android:layout_height="fill_parent"
  15.         android:layout_weight="2"
  16.         android:contentDescription="@string/empty_string"
  17.         android:paddingRight="5dp" />
  18.  
  19.     <LinearLayout
  20.         android:layout_width="0dp"
  21.         android:layout_height="wrap_content"
  22.         android:layout_weight="8"
  23.         android:orientation="vertical" >
  24.  
  25.         <LinearLayout
  26.             android:layout_width="wrap_content"
  27.             android:layout_height="fill_parent"
  28.             android:orientation="horizontal" >
  29.  
  30.             <TextView
  31.                 android:id="@+id/post_offices_list_item_zipcode"
  32.                 style="@style/TextAppearance.Medium"
  33.                 android:layout_width="wrap_content"
  34.                 android:layout_height="wrap_content"
  35.                 android:gravity="center"
  36.                 android:paddingLeft="2dp"
  37.                 android:paddingRight="2dp" />
  38.  
  39.             <TextView
  40.                 android:id="@+id/post_offices_list_item_name"
  41.                 style="@style/TextAppearance.Medium"
  42.                 android:layout_width="wrap_content"
  43.                 android:layout_height="wrap_content"
  44.                 android:ellipsize="marquee"
  45.                 android:focusable="true"
  46.                 android:focusableInTouchMode="true"
  47.                 android:gravity="center"
  48.                 android:marqueeRepeatLimit="marquee_forever"
  49.                 android:scrollHorizontally="true"
  50.                 android:singleLine="true" />
  51.         </LinearLayout>
  52.  
  53.         <TextView
  54.             android:id="@+id/post_offices_list_item_address"
  55.             style="@style/TextAppearance.Medium"
  56.             android:layout_width="wrap_content"
  57.             android:layout_height="wrap_content"
  58.             android:ellipsize="marquee"
  59.             android:focusable="true"
  60.             android:focusableInTouchMode="true"
  61.             android:gravity="center"
  62.             android:marqueeRepeatLimit="marquee_forever"
  63.             android:scrollHorizontally="true"
  64.             android:singleLine="true" >
  65.         </TextView>
  66.     </LinearLayout>
  67.  
  68.     <TextView
  69.         android:id="@+id/post_offices_list_item_distance"
  70.         style="@style/TextAppearance.Large"
  71.         android:layout_width="0dp"
  72.         android:layout_height="fill_parent"
  73.         android:layout_weight="2"
  74.         android:gravity="center" />
  75.  
  76.     <ImageView
  77.         android:id="@+id/post_offices_list_item_next"
  78.         android:layout_width="0dp"
  79.         android:layout_height="wrap_content"
  80.         android:layout_weight="1"
  81.         android:layout_gravity="center_vertical"
  82.         android:contentDescription="@string/empty_string"
  83.         android:src="@drawable/postakereso_list_next" />
  84.  
  85. </LinearLayout>

This is how to add data to the list:

  1. listView = (ListView) findViewById(R.id.postofficeslist);
  2.         listAdapter = new PostOfficesListAdapter(new ArrayList<PostOffice>());
  3.         listView.setAdapter(listAdapter);

The adapter fills out the list items (only the essential parts):

  1. convertView = LayoutInflater.from(PostaApplication.getContext()).inflate(getItemLayout(), null);
  2.  
  3.         ItemViewHolder holder = (ItemViewHolder) convertView.getTag();
  4.         if (holder == null) {
  5.         holder = new ItemViewHolder();
  6.         holder.name = (TextView) convertView.findViewById(R.id.post_offices_list_item_name);
  7.         holder.zipCode = (TextView) convertView.findViewById(R.id.post_offices_list_item_zipcode);
  8.         holder.address = (TextView) convertView.findViewById(R.id.post_offices_list_item_address);
  9.         holder.distance = (TextView) convertView.findViewById(R.id.post_offices_list_item_distance);
  10.         holder.type = (ImageView) convertView.findViewById(R.id.post_offices_list_item_type_image);
  11.         convertView.setTag(holder);
  12.         }
  13.         if (postOffice != null) {
  14.                 holder.name.setText(postOffice.getName());
  15.                 holder.name.setSelected(true);
  16.                 holder.address.setText(postOffice.getAddress());
  17.                 holder.address.setSelected(true);
  18.                 holder.zipCode.setText(postOffice.getZipcode());
  19.                 holder.distance.setText(StringUtils.getFormattedDistance(postOffice.getDistance()));
  20.         }

The same in Windows:

List descriptor xaml

  1. <ListBox x:Name="Addresses"
  2.      Margin="15,0,15,15"
  3.      ItemTemplate="{StaticResource PostalListDataTemplate}"
  4.             SelectionChanged="Addresses_SelectionChanged" />

List item descriptor xaml:

  1.    <DataTemplate x:Key="PostalListDataTemplate">
  2.         <StackPanel>
  3.             <Grid>
  4.                 <Grid.ColumnDefinitions>
  5.                     <ColumnDefinition Width="0.7*" />
  6.                     <ColumnDefinition Width="3*" />
  7.                     <ColumnDefinition Width="1*" />
  8.                     <ColumnDefinition Width="0.04*" />
  9.                     <ColumnDefinition Width="0.15*" />
  10.                 </Grid.ColumnDefinitions>
  11.                 <Image Source="{Binding typeImage}"
  12.                        Grid.Column="0"
  13.                        Margin="5,5,5,5" />
  14.                 <StackPanel HorizontalAlignment="Left"
  15.                             Grid.Column="1"
  16.                             Margin="5,5,0,5">
  17.                     <controls:LocalizedText   Text="{Binding zipAndCity}"
  18.                                               VerticalAlignment="Center"
  19.                                               HorizontalAlignment="Left"
  20.                                               Style="{StaticResource Text.Normal.Medium}"></controls:LocalizedText>
  21.                     <controls:LocalizedText   Text="{Binding address}"
  22.                                               VerticalAlignment="Center"
  23.                                               HorizontalAlignment="Left"
  24.                                               Style="{StaticResource Text.Normal.Medium}"></controls:LocalizedText>
  25.                 </StackPanel>
  26.                 <StackPanel HorizontalAlignment="Right"
  27.                             Grid.Column="2"
  28.                             Margin="5,5,0,5">
  29.                     <controls:LocalizedText Margin="0"
  30.                                             Text="{Binding distanceString}"
  31.                                             TextAlignment="Center"
  32.                                             VerticalAlignment="Center"
  33.                                             HorizontalAlignment="Right"
  34.                                             Style="{StaticResource Text.Normal.Medium}"></controls:LocalizedText>
  35.                     <controls:LocalizedText Margin="0"
  36.                                             Text="{Binding distanceUnit}"
  37.                                             TextAlignment="Center"
  38.                                             VerticalAlignment="Bottom"
  39.                                             HorizontalAlignment="Right"
  40.                                             Style="{StaticResource Text.Normal.Medium}"></controls:LocalizedText>
  41.                 </StackPanel>
  42.                 <StackPanel Grid.Column="4"
  43.                             VerticalAlignment="Center">
  44.                     <Image Source="ms-appx:///Resources/Images/PostalServicesLocations/postakereso_list_NEXT.png"
  45.                            VerticalAlignment="Center"
  46.                            HorizontalAlignment="Center" />
  47.                 </StackPanel>
  48.             </Grid>
  49.             <Image Source="ms-appx:///Resources/Images/Tracking/<a href="mailto:trackingdetail_line@2x.png">trackingdetail_line@2x.png</a>" />
  50.         </StackPanel>
  51.     </DataTemplate>

This is how to add the data to the list:

  1. Addresses.ItemsSource = offices;

For example to add the zipcode for the post office this is what's needed:

On Android

- The list in layout

  1. <ListView  android:id="@+id/postofficeslist"

- Ask for the list in code

  1. listView = (ListView) findViewById(R.id.postofficeslist);

- Configure the list for the adapter

  1. listAdapter = new PostOfficesListAdapter(new ArrayList<PostOffice>());
  2. listView.setAdapter(listAdapter);

- Adapter sets the list item layout

  1. convertView = LayoutInflater.from(PostaApplication.getContext()).inflate(getItemLayout(), null);

- Ask for the appropriate adapter list item elements

  1. holder.zipCode = (TextView) convertView.findViewById(R.id.post_offices_list_item_zipcode);

- Adapter sets the value of this element

  1. style="text-align: justify;">holder.zipCode.setText(postOffice.getZipcode());

On Windows

- The list in layout

  1. <ListBox x:Name="Addresses"  . . .

- Set list item layout to list

  1. ItemTemplate="{StaticResource PostalListDataTemplate}"

- Set data binding in list item layout

  1. <controls:LocalizedText   Text="{Binding zipAndCity}" . . .

- Set data source to list in c# code

  1. Addresses.ItemsSource = offices;

The difference can be seen this time it's in favor of Windows.
This is just a random examples, the picture is more nuanced. On both platforms there are several widgets required on a real project what cannot be handled using the built-in basic elements. In such cases We had to develop our own UI elements. In this respect, the Android is a better.
All in all, both languages have their advantages and disadvantages. In some cases where Android is leading the way, and other cases where Windows does. They require a slightly different development techniques, so I cannot make a difference.

So this round 1-1

Final scoring i.e. conclusion:

If we add up all the round scores, then android won 6-4. This is broadly consistent with the image what I had in my mind before we analyzed everything in parts. It also includes the fact that if we go skip the initial difficulties and we only look the development of the later projects, there isn't much difference between the two systems. If online support would be better on Windows, then the subjective opinion of the whole complex would be matched.
If I had written this post half a year earlier then the difference would have been greater in favor of the Android. Another half years later, the differences may disappear completely.

Comments (1)
3
3
Friday, September 18, 2015 - 14:44
Some years ago I have used an Android emulator quite well. In that case the problem was that the emulator run much slower, not faster, than the actual phone/tablet, due to micro-instructions rewrite (from Intel to ARM processor). I am saying this as a reply to the section describing the Microsoft emulator and the apparent lack of an Android emulator.