This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Posts tagged: Xamarin

Xamarin Client (simple PoC)

What is Xamarin?

Read all details here.

It's a company and a really cool platform for mobile application development. It enables you to use one codebase for iOS and Android.

Since 2016, it's more or less free for everyone.

We tried Xamarin some years before 2016 and it wasn't free. So it wasn't an option for us. Not because it's using C# as programming language. We already have mobile clients for JVx applications but they don't share the same codebase. There is one client for Android and another one for iOS. The source code is licensed under Apache 2.0.

Our native clients work great but we think they could be better.

In the last days we made some tests with different tools, to create a new universal client with one technology. A HTML5 client wasn't an option for us because of different criterias. A real native client was important during our evaluation.

Some links to different opinions:

We made good first progress with Xamarin and because of its pricing, it was the winner of our evaluation. Sure, Xamarin is C# but it's better to write C# than JavaScript. Another plus was that we already have a simple JVx connection port to .NET based on C#. So we could reuse this code.

Why not JavaFX?

The problem with JavaFX is, that it's unclear what will happen with JavaFX in the future. There are different articles about the future of JavaFX, but the one from Jonathan Giles makes it clear

Sure, there's Gluon and some other individual developers, but the overall performance isn't relly comparable to native apps. It's awesome what happened in the last years, but the progress is missing.

We still have our JavaFX based UI, but we're not sure if JavaFX will survive or it will be commercialized. So it's better to have an option.

Why not CodenameOne?

It's a really cool technology and works great with some smaller performance glitches (simply try the current KitchenSink from the App stores)..
WORA just works!

The cloud build isn't what we prefer and the pricing is not good for our use-case. Our client should be free, open and easy to use for every developer.

Here is a simple test application for REST access to our Heroes application, used in our Angular test application.

iOS client

iOS client

Android client

Android client

The source code for this test:

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
using Xamarin.Forms;

namespace TableViewSamples
{
  public class RESTTable : ContentPage
  {
    public RESTTable()
    {
      GetData();
    }

    async void GetData()
    {
      this.Title = "REST Data";
      var table = new TableView() { Intent = TableIntent.Data };
      var root = new TableRoot();
      var section1 = new TableSection() { Title = "First Section" };

      var authData = string.Format("{0}:{1}", "user", "pwd");
      var authHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authData));

      HttpClient client = new HttpClient();
      client.DefaultRequestHeaders.Authorization =
        new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authHeaderValue);
      HttpResponseMessage response = await client.GetAsync("https://...");

      if (response.IsSuccessStatusCode)
      {
          HttpContent content = response.Content;

          var result = await content.ReadAsStringAsync();

          var parsed = JsonConvert.DeserializeObject<List<HEROES>>(result);

          foreach (var record in parsed)
          {
              System.Diagnostics.Debug.WriteLine("Data: {0}", record);

              section1.Add(new TextCell { Text = record.NAME });
          }
      }

      table.Root = root;
      root.Add(section1);

      Content = table;
    }
  }

  public class HEROES
  {
    public int ID { get; set; }
    public string NAME { get; set; }
  }
}