【发布时间】:2017-12-14 07:08:43
【问题描述】:
我只想将 Zebble 用于生成 UI 和所有其他我想使用 Xamarin apis/custom http apis/local db 或其他任何东西的东西。基本上一个带有 zebble 和其他东西的 UI 项目将在 PCL 中。
会兼容吗?可以请教吗?
【问题讨论】:
标签: xamarin-zebble
我只想将 Zebble 用于生成 UI 和所有其他我想使用 Xamarin apis/custom http apis/local db 或其他任何东西的东西。基本上一个带有 zebble 和其他东西的 UI 项目将在 PCL 中。
会兼容吗?可以请教吗?
【问题讨论】:
标签: xamarin-zebble
是的,你可以。 Zebble 中没有任何东西可以阻止您直接使用本机 API。
对于自定义 http 调用,我建议使用 HttpClient 类,默认情况下该类在新创建的 Zebble 项目的所有 3 个平台中都可用。
对于设备 API,您当然可以使用每个平台的标准 API 类,但为了节省时间并实现 100% 代码重用,我强烈建议使用http://zebble.net/docs/device-api。例如,如果您想使用灯泡(又名闪光灯、led 或手电筒),您可以非常轻松地在所有平台上实现,只需很少的代码:
// Determines if a lamp feature is available on the device.
if (await Device.Torch.IsAvailable()) { ... }
// This will switch the lamp on.
await Device.Torch.TurnOn();
// This will switch the lamp off.
await Device.Torch.TurnOff();
【讨论】: