{"id":13837,"date":"2017-02-09T03:30:04","date_gmt":"2017-02-08T18:30:04","guid":{"rendered":"https:\/\/jirak.net\/wp\/announcing-project-rome-android-sdk\/"},"modified":"2017-02-09T03:34:26","modified_gmt":"2017-02-08T18:34:26","slug":"announcing-project-rome-android-sdk","status":"publish","type":"post","link":"https:\/\/jirak.net\/wp\/announcing-project-rome-android-sdk\/","title":{"rendered":"Announcing Project Rome Android SDK"},"content":{"rendered":"<p>Announcing Project Rome Android SDK<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jirak.net\/wp\/wp-content\/uploads\/2017\/02\/Picture1.png\" width=\"947\" height=\"253\"><\/p>\n<h2>Project Rome Overview<\/h2>\n<p><strong>Project Rome<\/strong> is a platform for creating experiences that transcend a single device and driving up user engagement \u2013 empowering a developer to create human-centric scenarios that move with the user and blur the lines between their devices regardless of form factor or platform.<\/p>\n<p>We first shipped Project Rome capabilities for Remote Launch and Remote App Services in Windows 10 Anniversary Update.<\/p>\n<h2>Project Rome Android SDK<\/h2>\n<p><a href=\"https:\/\/winblogs.azureedge.net\/win\/2017\/02\/Picture1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43967\" src=\"https:\/\/winblogs.azureedge.net\/win\/2017\/02\/Picture1.png\" alt=\"\" width=\"947\" height=\"253\" \/><\/a><\/p>\n<p>Today we are excited to announce the release of the <strong>Android version of the Project Rome SDK<\/strong>.\u00a0 This Android SDK works both with Java and with Xamarin.<\/p>\n<p>You can download the Project Rome SDK for Android at &lt;a href=&quot;https:\/\/github.com\/Microsoft\/project-rome\/tree\/master\/Project%20Rome%20for%20Android%20(preview%20release)<\/a>).<\/p>\n<h2>Capabilities exposed through the Project Rome Android SDK<\/h2>\n<p>Let\u2019s take an example of an app that might need this capability. In the last <a href=\"https:\/\/blogs.windows.com\/buildingapps\/2016\/10\/11\/cross-device-experience-with-project-rome\/\">blog post<\/a>, we had talked about Paul and his Contoso Music App. In that scenario, Paul had his UWP app which was a music player, and he wanted to make sure that his users had a way to communicate between his app as they moved between devices.<\/p>\n<p><a href=\"https:\/\/winblogs.azureedge.net\/win\/2017\/02\/Picture2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-43964\" src=\"https:\/\/winblogs.azureedge.net\/win\/2017\/02\/Picture2.png\" alt=\"\" width=\"975\" height=\"695\" \/><\/a><\/p>\n<p>If we take that example further, we can imagine that Paul has a Contoso Music App for Android as well. Paul notices that most of his users use his app on Windows, and on Android. These are the same users logged in with the same MSA. Paul wants to make sure that his users\u2019 experience translates well when they move between their Android and Windows devices. Paul also notices that many of his Windows users run his UWP app on their Xbox at home.<\/p>\n<p>With the Project Rome Android SDK Paul can use:<\/p>\n<ol>\n<li>The Remote Systems API to discover other Windows devices that the user owns. The Remote Systems APIs will allow the Contoso Music app to discover these devices on the same network, and through the cloud.<\/li>\n<li>Once discovered, the Remote Launch API will launch his app on another Windows device.<\/li>\n<li>Once his app is launched on the other device, Paul can use remote app services to control his app running on Windows from his Android device. We are not releasing this functionality in the release today, but it is coming soon in a future release of the Android SDK.<\/li>\n<\/ol>\n<p>Thus, using the Project Rome Android SDK, Paul can bridge the experience gap that exists as his users move between their Android and Windows devices.<\/p>\n<h2>Capability Walkthrough<\/h2>\n<p>We will briefly walk through both a Java and Xamarin example.\u00a0 We have full examples of UWP here: <a href=\"https:\/\/github.com\/Microsoft\/Windows-universal-samples\/tree\/dev\/Samples\/RemoteSystems\">https:\/\/github.com\/Microsoft\/Windows-universal-samples\/tree\/dev\/Samples\/RemoteSystems<\/a> and Android here: <a href=\"https:\/\/github.com\/Microsoft\/project-rome\/tree\/master\/Project%20Rome%20for%20Android%20(preview%20release)\">https:\/\/github.com\/Microsoft\/project-rome\/tree\/master\/Project%20Rome%20for%20Android%20(preview%20release)<\/a>.<\/p>\n<h3>Click on the image below to see the Android Sample app in action:<\/h3>\n<p><a href=\"https:\/\/microsoft.sharepoint.com\/teams\/WDGProjectRome\/_layouts\/15\/AccessDenied.aspx?Source=https%3A%2F%2Fmicrosoft%2Esharepoint%2Ecom%2Fteams%2FWDGProjectRome%2FShared%20Documents%2FblogVideo%2Emp4&amp;correlation=e8d2d29d-70e9-0000-5037-116c6368d023&amp;Type=item&amp;name=f6c78105-b841-4344-853c-3cccf4d10946&amp;listItemId=108\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-43961 size-full\" src=\"https:\/\/winblogs.azureedge.net\/win\/2017\/02\/Picture3.png\" width=\"269\" height=\"478\" \/><\/a><\/p>\n<h3>Using Java<\/h3>\n<p>Here are snippets in Java from our sample of how you\u2019d use the Project Rome Android SDK.\u00a0 The first step to get going with the Android SDK is to initialize the platform, where you\u2019ll handle authentication.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\">\r\n\r\nPlatform.initialize(getApplicationContext(), new IAuthCodeProvider() {\r\n    @Override\r\n    public void fetchAuthCodeAsync(String oauthUrl, Platform.IAuthCodeHandler authCodeHandler) {\r\n        performOAuthFlow(oauthUrl, authCodeHandler);            \r\n    }\r\n}\r\n\r\n<\/pre>\n<p>Using OAuth you\u2019ll retrieve an auth_code via a WebView:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\">\r\n\r\npublic performOAuthFlow (String oauthUrl, Platform.IAuthCodeHandler authCodeHandler) {\r\n\r\n    WebView web;\r\n    web = (WebView) _authDialog.findViewById(R.id.webv);\r\n    web.setWebChromeClient(new WebChromeClient());\r\n    web.getSettings().setJavaScriptEnabled(true);\r\n    web.getSettings().setDomStorageEnabled(true);\r\n\r\n    \/\/ Get auth_code\r\n    web.loadUrl(oauthUrl);\r\n\r\n    WebViewClient webViewClient = new WebViewClient() {\r\n        boolean authComplete = false;\r\n        @Override\r\n        public void onPageFinished(WebView view, String url) {\r\n            super.onPageFinished(view, url);\r\n\r\n            if (url.startsWith(REDIRECT_URI)) {\r\n                Uri uri = Uri.parse(url);\r\n                String code = uri.getQueryParameter(&amp;amp;quot;code&amp;amp;quot;);\r\n                String error = uri.getQueryParameter(&amp;amp;quot;error&amp;amp;quot;);\r\n                if (code != null &amp;amp;amp;&amp;amp;amp; !authComplete) {\r\n                authComplete = true;\r\n                authCodeHandler.onAuthCodeFetched(code);\r\n                } else if (error != null) {\r\n                  \/\/ Handle error case                                    }\r\n            }\r\n         }\r\n    };\r\n\r\n    _web.setWebViewClient(webViewClient);\r\n}\r\n\r\n<\/pre>\n<p>Now, discover devices:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\">\r\n\r\nRemoteSystemDiscovery.Builder discoveryBuilder;\r\ndiscoveryBuilder = new RemoteSystemDiscovery.Builder().setListener(new IRemoteSystemDiscoveryListener() {\r\n    @Override\r\n    public void onRemoteSystemAdded(RemoteSystem remoteSystem) {\r\n        Log.d(TAG, &amp;amp;quot;RemoveSystemAdded = &amp;amp;quot; + remoteSystem.getDisplayName());\r\n        devices.add(new Device(remoteSystem));\r\n        \/\/ Sort devices\r\n        Collections.sort(devices, new Comparator&amp;amp;lt;Device&amp;amp;gt;() {\r\n            @Override\r\n            public int compare(Device d1, Device d2)\r\n            {\r\n                return d1.getName().compareTo(d2.getName());\r\n            }\r\n        });\r\n       }\r\n});\r\nstartDiscovery();\r\n\r\n<\/pre>\n<p>Remote launch a URI to your device:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\">\r\n\r\nnew RemoteSystemConnectionRequest(remoteSystem)\r\nString url = &amp;amp;quot;http:\/\/msn.com&amp;amp;quot;\r\n\r\nnew RemoteLauncher().LaunchUriAsync(connectionRequest,\r\n        url,\r\n        new IRemoteLauncherListener() {\r\n            @Override\r\n            public void onCompleted(RemoteLaunchUriStatus status) {\r\n\r\n            \u2026\r\n            }\r\n        };\r\n\r\n<\/pre>\n<h3>Using Xamarin<\/h3>\n<p>Similarly, here are snippets in Xamarin.<\/p>\n<p>You will first initialize the Connected Devices Platform:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\">\r\n\r\nPlatform.FetchAuthCode += Platform_FetchAuthCode;\r\nvar result = await Platform.InitializeAsync(this.ApplicationContext, CLIENT_ID);\r\n\r\n<\/pre>\n<p>Using OAuth you\u2019ll retrieve an auth_code:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\">\r\n\r\nprivate async void Platform_FetchAuthCode(string oauthUrl)\r\n{\r\n    var authCode = await AuthenticateWithOAuth(oauthUrl);\r\n    Platform.SetAuthCode(token);\r\n}\r\n\r\n<\/pre>\n<p>Now, discover devices:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\">\r\n\r\nprivate RemoteSystemWatcher _remoteSystemWatcher;\r\nprivate void DiscoverDevices()\r\n{\r\n    _remoteSystemWatcher = RemoteSystem.CreateWatcher();\r\n    _remoteSystemWatcher.RemoteSystemAdded += (sender, args) =&amp;amp;gt;\r\n    {\r\n        Console.WriteLine(&amp;amp;quot;Discovered Device: &amp;amp;quot; + args.P0.DisplayName);\r\n    };\r\n    _remoteSystemWatcher.Start();\r\n}\r\n\r\n<\/pre>\n<p>Finally, connect and launch URIs using LaunchUriAsync:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\">\r\n\r\nprivate async void RemoteLaunchUri(RemoteSystem remoteSystem, Uri uri)\r\n{\r\n    var launchUriStatus = await RemoteLauncher.LaunchUriAsync(new RemoteSystemConnectionRequest(remoteSystem), uri);\r\n}\r\n\r\n<\/pre>\n<p>If you want to see the Xamarin code, please head over to <a href=\"https:\/\/github.com\/Microsoft\/project-rome\/tree\/master\/xamarin\">https:\/\/github.com\/Microsoft\/project-rome\/tree\/master\/xamarin<\/a>.<\/p>\n<h2>Wrapping Up<\/h2>\n<p>Project Rome breaks down barriers across all Windows devices and creates experiences that are no longer constrained to a single device. With today\u2019s announcement, we are bringing this capability to Android devices as well. The Remote Systems API available in Windows 10 is a key piece of Project Rome that provides exposure of the device graph and the ability to connect and command \u2013 this is fundamental for driving user engagement and productivity for applications across <strong>all devices<\/strong>.<\/p>\n<p>To learn more and browse sample code, including the snippets shown above, please check out the following articles and blog posts:<\/p>\n<ul>\n<li><a href=\"https:\/\/blogs.windows.com\/buildingapps\/2016\/10\/11\/cross-device-experience-with-project-rome\/\">Overview of Project Rome APIs on Building apps for Windows<\/a><\/li>\n<li><a href=\"https:\/\/msdn.microsoft.com\/windows\/uwp\/launch-resume\/connected-apps-and-devices\">MSDN Connected Apps and Devices (Project Rome)<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/Microsoft\/Windows-universal-samples\/tree\/dev\/Samples\/RemoteSystems\">GitHub Remote Systems API sample<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/project-rome\/quickstart-discover-launch-command\">GitHub Project Rome: Discover Launch Command<\/a><\/li>\n<li><a href=\"https:\/\/msdn.microsoft.com\/windows\/uwp\/launch-resume\/how-to-create-and-consume-an-app-service\">MSDN Create and Consume an App Service<\/a><\/li>\n<\/ul>\n<p><em>The Windows team would love to hear your feedback.\u00a0 Please keep the feedback coming using our\u00a0<\/em><a href=\"https:\/\/wpdev.uservoice.com\/\">Windows Developer UserVoice site<\/a><em>. If you have a direct bug, please use the Windows Feedback tool built directly into Windows 10.<\/em><\/p>\n<p>Source: <a href=\"http:\/\/blogs.windows.com\/buildingapps\/2017\/02\/08\/announcing-project-rome-android-sdk\/\" target=\"_blank\">Announcing Project Rome Android SDK<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Announcing Project Rome Android SDK Project Rome Overview Project Rome is a platform for creating experiences that transcend a single device and driving up user engagement \u2013 empowering a developer to create human-centric scenarios that move with the user and blur the lines between their devices regardless of form factor or platform. We first shipped Project Rome capabilities for Remote Launch and Remote App Services in Windows 10 Anniversary Update. Project Rome Android SDK Today we are excited to announce the release of the Android version of the Project Rome SDK.\u00a0 This Android SDK works both with Java and with Xamarin. You can download the Project Rome SDK for Android at &lt;a href=&quot;https:\/\/github.com\/Microsoft\/project-rome\/tree\/master\/Project%20Rome%20for%20Android%20(preview%20release)). Capabilities exposed through the Project Rome Android SDK Let\u2019s take an example of an app that might need this capability. In the last blog post, we had <a class=\"mh-excerpt-more\" href=\"https:\/\/jirak.net\/wp\/announcing-project-rome-android-sdk\/\" title=\"Announcing Project Rome Android SDK\">[ more&#8230; ]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":13838,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[169],"tags":[201],"class_list":["post-13837","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-windows"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts\/13837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/comments?post=13837"}],"version-history":[{"count":1,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts\/13837\/revisions"}],"predecessor-version":[{"id":13839,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/posts\/13837\/revisions\/13839"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/media\/13838"}],"wp:attachment":[{"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/media?parent=13837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/categories?post=13837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jirak.net\/wp\/wp-json\/wp\/v2\/tags?post=13837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}