简体   繁体   中英

How do I use Windows namespaces in Xamarin (iOS and Android) app?

I understand there are Windows specific APIs. But is there any guide or tutorial to build an app that needs to use some Windows API? And also how can I port some UWP apps , to Xamarin (iOS and Android)?

For example, can I just simply use namespaces/libraries in Xamarin's shared code project without having UWP project?

using Windows.AI.MachineLearning;
using Windows.Devices;

My intention is to build an Andoid or iOS app that can interact with Windows OS via device-protocol agnostic connection.

You can use these Windows-specific namespaces in your shared project but only with conditional #if WINDOWS_UWP compilation directives. More reading on how to do that is here .

Even though you can write this code in your shared project, it will be compiled only when you build it with a UWP target project. When you try to build your project for iOS or Android, these lines will be omitted and you won't be able to use windows specific API in your target project.

In order to provide MachineLearning capabilities in your iOS and Android app, you want to implement platform-specific service supporting these capabilities, Tensorflow for Android and Core ML for iOS .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM