【问题标题】:Xamarin C#: how to add resource to intentfilter metadata for USB connection ReceiverXamarin C#:如何为 USB 连接接收器的 Intentfilter 元数据添加资源
【发布时间】:2016-05-17 01:10:11
【问题描述】:

这个名为“UsbFilter”的XML文件保存在“Resources/xml”中:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <usb-accessory model="EVK1105" manufacturer="Atmel" version="1.0"/>
</resources>

我现在想在 USB 配件连接到我的手机时将其用于我的 intentfilters 元数据,因此我在广播接收器实现的顶部执行此操作:

[BroadcastReceiver(Enabled = true, Label = "UsbConnectReciever")]
    [IntentFilter(new[]
    {
        UsbManager.ActionUsbAccessoryAttached
    })]
    [MetaData(UsbManager.ActionUsbAccessoryAttached, Resource = "xml/UsbFilter")]

但是,当它尝试构建时出现此错误:

String types not allowed (at 'resource' with value 'xml/UsbFilter).

但它真的不是一个字符串! 如果我尝试使用“@”,我会收到此错误:

No resource found that matches the given name (at 'resource' with value '@xml/UsbFilter).

那么我怎样才能做到这一点呢? 谢谢。

【问题讨论】:

    标签: c# android xml xamarin usb


    【解决方案1】:

    原来它不仅需要“@”,而且还必须全部小写

    【讨论】:

      猜你喜欢
      • 2020-03-18
      • 1970-01-01
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      • 2019-06-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多