Treehopper C# API
|
Treehopper supports C# Android apps written in Xamarin.Android.
You can use Visual Studio or Visual Studio for Mac to build Android apps in C#.
You can connect to Treehopper boards without declaring a manifest or device filter, but if you want your app to be started automatically when you plug in a board, create a device filter, such as:
To get ConnectionService working properly, it needs access to the MainActivity. To make this less tedious, the Treehopper.Android ConnectionService implements additional methods you must call from OnStart and OnResume, like so:
Just like with other C#-based Treehopper projects, you'll need a reference to a connected TreehopperUsb board, which will arrive asynchronously.
You can also monitor CollectionChanged events generated by the ConnectionService.Instance.Boards ObservableCollection.
While it is always a good idea to check the ConnectionService.Instance.Boards collection to see if a board has already been added (and thus, will not fire a CollectionChanged event), this usually isn't necessary for Android applications, as the permission authorization user interface routines are quite time-consuming (that is, unless an intent filter has been created).