dimanche 1 septembre 2019

XAMARIN Tizen for Tvs and .NET Standard 2.0 [9-2019][XAML, C#]

My return of Experience on XAMARIN for TIZEN TVs the 1st of September 2019.

Here is documentation where you can find about Xamarin Forms for Tizen:

After a long summer of slowly migrating all of my app libraries to .NET Standard 2 I could finally really test Tizen to see how much code I could share between my Xbox One UWP app and a new Tizen TV app.

Framework versions:
  • Tizen.NET (5.0.0.14562)
  • Tizen.TV.UIControls (1.0.0)
  • Tizen.NET.Sdk (1.0.1) (this nuget would not update to the latest version 1.0.3)
  • Xamarin.Forms(4.1.0.709249) (forms 4.2.0.709249 was generating an error when building the app)

I discovered a new library called Tizen.TV.UIControls  which greatly improve the UI layout for the TV.  This library contains awesome features like:

MediaPlayer












RecycleItemsView


Horizontal lists


 
 
You can find the github repo here.

Tizen TV Xamarin C#


To get started I wanted to do a simple HTTP call to get data and set this data into a horizontal list, well I never got passed this step...

As for all applications you need to tell the app that it will have special privileges.  First you will need to start by adding  http://tizen.org/privilege/internet which is located in the file tizen-manifest.xml and then the tab Privileges. 

Next here is the code I am using to get weather information:


HttpClient client;
        private async System.Threading.Tasks.Task GetWeatherServiceAsync()
        {             
            var uri = new Uri("https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22");

            try
            {
                client = new HttpClient();

                var response = await client.GetAsync(uri);

                if (response.IsSuccessStatusCode)
                {
                    var responseContent = await response.Content.ReadAsStringAsync();

                }
            }
            catch (Exception ex)
            {
                var error = ex;
            }

        }


And the issue is that no matter what I tried client would never be initialized:



So as of today I cant do an HTTP call on my Tizen .NET Xamarin application, ill keep you posted as soon as I find a solution.

After looking more closely at all of the GitHub Sample for Tizen TV app they all generate their sample data by hand which probably means that their is an issue somewhere for TV apps, I do hope Samsung fix this ASAP as a TV app without being able to do HTTP calls is not very practical...


Happy coding

- UPDATE 5 Septembre 2019 - 
After discussion with Samsung it was found that I was using an old build of the Tizen emulator.
BuildInfo: "tizen_20181210.1228946"
BuildDate : "20181210_063435"

When I should have been using a 2019 Build, once I updated to the latest build everything was working.  IMO inside Visual Studio I wish I have had a warning telling me that I was using an old build.