CTXUG Monthly Meetup 1 March 2017

Tonight was a very fun evening at CTXUG (Cape Town Xamarin User’s Group).      The two topics presented were Telerik UI for Xamarin and Lottie.       The User Group was held at the MLab office at the waterfront which is a great place to have events!

 

Event URL:  https://www.meetup.com/Cape-Town-Xamarin-Users-Group/events/237781504/

 

Telerik UI

 

“Telerik® UI for Xamarin by Progress is a collection of UI controls and functionalities that complement the default controls found in the platform. The controls offer many non-trivial scenarios out of the box, helping developers to implement polished UI with native-quality performance in their apps faster, shortening time to market. Telerik UI for Xamarin includes Xamarin.iOS wrappers, Xamarin.Android wrappers and Xamarin.Forms controls.”

 

I did the first talk this time on Telerik UI for Xamarin.      It was great showing off what the component set could do, and everyone seemed inspired and impressed with what Telerik UI for Xamarin offers.

 

I do hope the free Telerik license recipients will be presenting the cool stuff they build soon at CTXUG!!!  🙂

 

Thank you to Telerik for all the giveaways!!

 

Speaker:   Allan Pead

 

The slides for this can be found on github:    http://bit.ly/2mGtt61

 

More details on Telerik UI for Xamarin can be found here:  http://www.telerik.com/campaigns/xamarin-ui/telerik-ui-for-xamarin

 

Photos

 

Telerik UI For Xamarin Talk

 

Telerik Swag

 

Lottie

Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!

For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand.”

 

Chris van Wyk  (from Xamarin University) gave an amazing talk on the amazing animation framework Lottie.   Everyone (including myself) was really, really impressed what Lottie can do.

 

Speaker:   Chris van Wyk

 

More information about Lottie:  https://github.com/martijn00/LottieXamarin

 

Photos

 

Lottie Talk

 

 

I hope to see everyone at CTXUG soon!  <Update> The next User Group meetup is on the 29th of March.   The topic will be Visual Studio 2017!!

 

Android Things GPIO Callbacks

Following the blog post to get you up and running with Android Things, Visual Studio and Xamarin.  http://explorationspace.co.za/2017/02/26/using-xamarin-and-visual-studio-with-android-things/

 

Android Things has GPIO callbacks which are triggered on certain trigger events.    This is great for event handling.    I’ve added a sample to Xamarin bindings which illustrates this by means of a Grove PIR (Passive InfraRed) sensor much like what’s in your home alarm system.   If we use that in conjunction with a buzzer, you have a primitive alarm system.

 

The source can be found here:   https://github.com/apead/Xamarin-Android-Things

 

Intel Edison with PIR and Buzzer

 

 

Gpio callbacks are classes implemented inheriting from the abstract class Gpio Callback.    This call back is triggered on certain trigger types.   This are set on the gpio pin with the settriggertype method.

  • EDGE_NONE: No interrupt events. This is the default value.
  • EDGE_RISING: Interrupt on a transition from low to high
  • EDGE_FALLING: Interrupt on a transition from high to low
  • EDGE_BOTH: Interrupt on all state transitions

 

 public class AlarmCallback : Com.Google.Android.Things.Pio.GpioCallback
 {
 public Gpio BuzzerPin { get; set; }

 public override bool OnGpioEdge(Gpio p0)
 {
 if (p0.Value)
 {
 if (!BuzzerPin.Value)
 {
 BuzzerPin.Value = true;
 Thread.Sleep(1000);
 BuzzerPin.Value = false;
 }
 }

 return true;
 }

 public override void OnGpioError(Gpio p0, int p1)
 {
 Log.Info("Alarmcallback", "Error");
 }
 }

 

The class has two methods to override.   OnGpioEdge and OnGpioError.     The OnGpioEdge method is called on a trigger event.     The OnGpioError is called on an error.

 

This class is registered on the actual input gpio pin.


_callback = new AlarmCallback {BuzzerPin = _buzzerGpio};

_alarm1Gpio.RegisterGpioCallback(_callback);

 

Happy Android Things development with Xamarin!

 

Using Xamarin and Visual Studio with Android Things

Android Things is Google’s new IOT Android based platform.    In essence it’s a slightly altered version of Android which can run on Iot type devices such as the Intel Edison and the Raspberry Pi3.

 

“Android Things lets you build professional, mass-market products on a trusted platform, without previous knowledge of embedded system design.”

 

Personally I’m not yet too impressed with Android Things.   It is still very new and very raw and is lacking a lot of what you’d expect from an Iot platform.   However, having finally a standard Android implementation officially from Google running on these devices has to be a good thing.    The platform should just get better from here.

 

 

 

Running in Visual Studio using Xamarin

 

Of course being Android, Android Things works with Xamarin too.     Using Xamarin will also be a benefit for all those awesome cross platform benefits it offers, like sharing your Iot code with your backend services, Android, Ios, Windows Phone, Windows 10, OSX, XBox and whatever other devices you’d like to be supporting in your solution.

 

Getting the devices to appear in Visual Studio is exactly as you’d expect.    The devices will use the standard Android Debugging Bridge (ADB).      Plugging in an Intel Edison via USB will be reflected as “Unknown Iot_Edison”.    You can obviously also use the network debugging features of ADB.   eg.   adb connect <ip address>   The device will then also be detected in Visual Studio.   A Raspberry Pi will appear as “Unknown iot_rpi3”.

 

Using Xamarin is very simple.    All we need to do is bind to the Android Things API Jar to be able to make use of all the features provided by the Android Things SDK.   At this moment in time there isn’t an official release Nuget package from Xamarin to do this.   It is however very simple to do this yourself.     In this sample (and I’ve shared the code on GitHub) I’m binding to the new Dev Preview 2 API for Android Things (androidthings-0.2-devpreview.jar).    Once the binding project is referenced from your Android Things project, everything will work as expected.   Just of course with the benefit of using C# and not Java!

 

I’ve created some samples based on the Standard Android Things Samples

 

Samples:   https://github.com/apead/Xamarin-Android-Things

Blink Led

No Iot sample and demo is complete without a blinking LED.   This sample is a conversion of the Android Things sample.

 

 

Simple UI

This sample is a simple illustration of using a UI on an Android Things device.   It also illustrates GPIO pins and how to set the high/low values of the pins.

 

Simple UI Android Things Sample

 

 

 

Learning Resources:

 

SDK Samples:  https://developer.android.com/things/sdk/samples.html

How to install Android Things on your Device:   https://developer.android.com/things/preview/index.html

A great article on the basics of electronics and hardware:  https://riggaroo.co.za/android-things-hardware-basics/

 

Happy Android Things Development with Xamarin!

Xamarin.Forms ContextActions, Binding and Mvvm Code Sample

How to bind a ContextAction in a Xamarin Forms ListView to a View Model?  This is a question I was asked recently.   I created a simple code sample for this, so thought I’d share it with everyone.

 

Below is a link to the sample on GitHub.    It includes an example of how to do it in code and in XAML.

 

 

https://github.com/apead/FormsMvvmContextActionSample

 

Happy Xamarin.Forms Coding!

Getting Started with .NET Core

.NET core is really easy to get up and running.     Download the installer relevant to your environment from https://www.microsoft.com/net/download/core   An IDE such as Visual Studio is optional.  I’m going to start with the command line version as it’s really quick to get running.   It also doesn’t need much resources for a development environment, which is great as I’m currently using a Samsung Tablet with 2 Gig of RAM to write this blog post.

 

There is a “Current” and a “LTS” version.   Choose which version suites your support needs.   “LTS” versions are supported for 3 years.   “Current” is the latest version, and is supported for 3 months.    I’m going to use “Current” here as it contains all the new juicy bits.

 

.NET Core Installer

 

The installer will take a minute or two to run.  Once installed, the executable “dotnet” will be added to the path.  Also different version of .NET will be installed side by side.

 

C:\blog\dotnet

Microsoft .NET Core Shared Framework Host

Version : 1.1.0
Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86

Usage: dotnet [common-options] [[options] path-to-application]

Common Options:
--help Display .NET Core Shared Framework Host help.
--version Display .NET Core Shared Framework Host version.

Options:
--fx-version &lt;version&gt; Version of the installed Shared Framework to use to run the application.
--additionalprobingpath &lt;path&gt; Path containing probing policy and assemblies to probe for.

Path to Application:
The path to a .NET Core managed application, dll or exe file to execute.

If you are debugging the Shared Framework Host, set 'COREHOST_TRACE' to '1' in your environment.

To get started on developing applications for .NET Core, install the SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

C:\blog\

 

To create a new app, there’s a “new” command.   On first execution it will extract and expand, which may take a moment.

 

Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.
Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include commandline arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Configuring...
-------------------
A command is running to initially populate your local package cache, to improve restore speed and enable offline access. This command will take up to a minute to complete and will only happen once.
Decompressing 100% 2294 ms
Expanding 100% 4502 ms

 

By default, the “dotnet new” command will create a console app. Issuing a “dotnet restore” command, all required packages will be fetched.

02/14/2017 03:01 PM &lt;DIR&gt; .
02/14/2017 03:01 PM &lt;DIR&gt; ..
02/14/2017 03:01 PM 0 dotnet
11/11/2016 12:10 AM 214 Program.cs
11/11/2016 12:10 AM 367 project.json
 3 File(s) 581 bytes
 2 Dir(s) 92,367,912,960 bytes free

C:\blog\dotnet restore
log : Restoring packages for C:\blog\project.json...
log : Writing lock file to disk. Path: C:\blog\project.lock.json
log : C:\blog\project.json
log : Restore completed in 899ms.

C:\blog\

 

To run the application simply type “dotnet run”.

C:\blog\dotnet run
Project blog (.NETCoreApp,Version=v1.1) will be compiled because expected outputs are missing
Compiling blog for .NETCoreApp,Version=v1.1

Compilation succeeded.
 0 Warning(s)
 0 Error(s)

Time elapsed 00:00:00.6861620


Hello World!

C:\blog\

 

There are various project types:  console, web, lib and xunittest.   The type can be specified with the -t parameter.  The language can be specified with the -l parameter.  The available languages are C# and F#

 

To create a ASP .NET Core / web app, type:   “dotnet new -t web”

 

C:\blog\web>dotnet new -t web
Created new C# project in C:\blog\web.

C:\blog\web>dir
Volume in drive C has no label.
Volume Serial Number is 4A07-921B

Directory of C:\blog\web

02/14/2017 03:12 PM <DIR> .
02/14/2017 03:12 PM <DIR> ..
11/11/2016 12:10 AM 36 .bowerrc
11/11/2016 12:10 AM 3,889 .gitignore
11/11/2016 12:10 AM 265 appsettings.json
11/11/2016 12:10 AM 214 bower.json
02/14/2017 03:12 PM <DIR> Controllers
02/14/2017 03:12 PM <DIR> Data
11/11/2016 12:10 AM 1,193 gulpfile.js
02/14/2017 03:12 PM <DIR> Models
11/11/2016 12:10 AM 239 package.json
11/11/2016 12:10 AM 574 Program.cs
11/11/2016 12:10 AM 3,397 project.json
11/11/2016 12:10 AM 2,229 README.md
02/14/2017 03:12 PM <DIR> Services
11/11/2016 12:10 AM 3,193 Startup.cs
02/14/2017 03:12 PM <DIR> Views
11/11/2016 12:10 AM 563 web.config
02/14/2017 03:12 PM <DIR> wwwroot
11 File(s) 15,792 bytes
8 Dir(s) 92,065,746,944 bytes free

C:\blog\web>

 

Running the web application is simple: the  “dotnet run” command will make this happen.   It will even host it in web container.

 

C:\blog\web>dotnet run
Project web (.NETCoreApp,Version=v1.1) will be compiled because expected outputs are missing
Compiling web for .NETCoreApp,Version=v1.1
C:\blog\web\project.json(5,30): warning NU1007: Dependency specified was Microsoft.NETCore.App >= 1.1.0-preview1-001153-00 but ended up with Microsoft.NETCore.App 1.1.0.

Compilation succeeded.
1 Warning(s)
0 Error(s)

Time elapsed 00:00:01.3100351
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0]
User profile is available. Using 'C:\Users\apead\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
Hosting environment: Production
Content root path: C:\blog\web
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
ASP .NET core landing page

 

Browsing to the URL presented:  “http://localhost:5000” will display the ASP .NET core default landing page.   This page is also quite useful as it contains links to various learning resources.

 

.NET core development can be done using any text editor, or in the cross platform lightweight editor Visual Studio Code, or if you prefer the full featured IDE Visual Studio.

 

Happy .NET core development!

 

 

 

 

Xamarin User Groups in South Africa

There are three Xamarin User Groups in South Africa.   Here you will find monthly topics which will include both .NET and Xamarin mobile related topics.

 

The groups are there to bring the Xamarin community together, where knowledge can be shared and experiences learnt from.    Hope you see you at an event soon!

 

Twitter:  https://twitter.com/ctxug

Cape Town Xamarin Users Group (@CTXUG)

Cape Town, ZA
170 Members

Calling everyone interested in cross platform mobile development. Specifically if you are interested in or using Xamarin tools. Or if you just want to talk mobile development …

Check out this Meetup Group →

Twitter:  https://twitter.com/gxugsa

Gauteng Xamarin User Group (@GXUGSA)

Johannesburg, ZA
179 Members

Calling everyone interested in cross platform mobile development. Specifically if you are interested in or using Xamarin tools. Or if you just want to talk mobile development …

Next Meetup

Motion & Xamarin.Forms

Tuesday, Mar 14, 2017, 6:30 PM
15 Attending

Check out this Meetup Group →

Twitter:  https://twitter.com/DXUGSA

Durban Xamarin User Group (@DXUGSA)

Durban, ZA
64 Members

Calling all cross platform developers, from Durban, that use Xamarin as their preferred tool of choice.

Check out this Meetup Group →

Xamarin and .NET automated builds and continuous integration (CTXUG)

Come join us for a very practical session on automating your Xamarin builds and setting up a continuous integration environment.

Leave here with skills to be able to use any CI tooling with Xamarin.

I am the speaker for this event.

 

Agenda 

1) Introduction to Continuous Integration

2) How does Xamarin build stuff behind the scenes?

Fundamentals of MSBUILD

Xamarin and MS Build

iOS build agent for Visual Studio

iOS and Android Packaging

3)  Setting up a continuous build server

The  code repository

Automating the build

4)  Test Cloud

 

We will also have a first look at Visual Studio Mobile Center.

 

Hope to see you there!

 

Update

 

The content is available here:  https://github.com/apead/XUGSABuildAutomation

Xamarin Dev Days South Africa

Xamarin Dev Days South Africa was amazing!   Thank you very much to all that attended and hope it was  worthwhile to take time off your busy scheduled to learn about Xamarin.

 

I am so proud to have been part of this and thank you to the team and all involved!

 

Xamarin Dev Days Cape Town

http://explorationspace.co.za/2016/09/30/xamarin-dev-days-cape-town-30-septemeber-2016/

 

Xamarin Dev Days Johannesburg

http://explorationspace.co.za/2016/09/23/xamarin-dev-days-johannesburg-23-september-2016/

 

Xamarin Dev Days South Africa

 

Xamarin Dev Days Cape Town 30 September 2016

Xamarin Dev Days Cape Town was definitely one of the prettiest dev days in world.   Thanks to all that came!

I’m so proud to have been part of  bringing Xamarin Dev Days to Africa for the first time.   May there be many more!!

 

What the day entailed:

 

Xamarin Dev Days Agenda

 

09:00 AM – 09:30 AM Registration

09:30 AM –  10:10 AM Intro Xamarin presentation

10:20 AM – 11:00 AM  Cross-platform Xamarin presentation

11:10 AM – 11:50 AM Cloud Xamarin presentation

12:00 PM – 12:45 PM Lunch

12:45 PM – 1:30 PM Sponsor speaker slot (Zebra)

01:30 PM – 16:30 PM Hackathon Challenge Walkthrough

 

Local Organizers & Xamarin Experts

Special thanks to the sponsors:

Microsoft South Africa   http://www.microsoft.com

Zebra Technologies  http://www.zebra.com

MLab  https://www.mlab.co.za/

AD Software Systems  http://www.adsoftsystems.co.za

 

The event in pictures:

 

Xamarin Dev Days with a View!

 

Rodger Weis on stage!

 

Martin on Stage!

 

Brent Samodien on Stage!

 

Lebo talking about MLab

 

Yummy Deserts!

 

Awesome turnout!

 

Awesome Venue!

 

Our awesome sponsor Zebra showcasing their devices

 

Lebo and Chris doing prep