project-rome/xamarin
Shawn Henry b03bf943c7 Metadata.xml cleanup 2017-04-13 11:02:37 -07:00
..
nuget Update to nuspec 2017-02-07 21:33:01 -08:00
samples/ConnectedDevices.Xamarin.Droid.Sample Task #11085280 : Added AppService to Xamarin projection and sample app 2017-03-07 16:10:59 -08:00
src Metadata.xml cleanup 2017-04-13 11:02:37 -07:00
LICENSE Added License 2017-01-26 21:15:26 -08:00
readme.md Update readme.md 2017-02-08 11:28:41 -08:00

readme.md

Project Rome Connected Devices Plugin for Xamarin on Android

Xamarin plugin to allow access to the Project Rome Connected Device APIs on Android. Discover, launch and message from Android application to Windows devices and applications.

Blog Post Walkthrough

Connected Apps and Devices

Setup

Platform Support

Platform Supported Version
Xamarin.Android Yes API 19+

API Usage

Pre-requisites

  1. Visual Studio 2015 or 2017 RC with Xamarin or Xamarin Studio
  2. Register your applciation and obtain an MSA client ID from https://apps.dev.microsoft.com

Getting Started

Initialize the Connected Devices Platform

Platform.FetchAuthCode += Platform_FetchAuthCode;
var result = await Platform.InitializeAsync(this.ApplicationContext, CLIENT_ID);

The FetchAuthCode handler is used when the platform needs an authorization code from the user (i.e. form OAuth with Microsoft Account). See the sample for more details.

private async void Platform_FetchAuthCode(string oauthUrl)
{
    var authCode = await AuthenticateWithOAuth(oauthUrl);
    Platform.SetAuthCode(token);
}

Now, discover devices

private RemoteSystemWatcher _remoteSystemWatcher;
private void DiscoverDevices()
{
    _remoteSystemWatcher = RemoteSystem.CreateWatcher();
    _remoteSystemWatcher.RemoteSystemAdded += (sender, args) =>
    {
        Console.WriteLine("Discovered Device: " + args.P0.DisplayName);
    };
    _remoteSystemWatcher.Start();
}

Finally, connect and launch URIs using LaunchUriAsync

private async void RemoteLaunchUri(RemoteSystem remoteSystem, Uri uri)
{
    var launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(remoteSystem), uri);
}

License

The MIT License (MIT)

Copyright (c) Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.