当我点击NFC标签时,我正试图让微软电话触发和事件。但是,当敲击标签时,该方法不会触发。 在点击标记时应该触发cardReader_CardAdded,但它什么都不做。 这是代码:
public MainPage()
{
this.InitializeComponent();
smartCard();
}
public async void smartCard()
{
string selector = SmartCardReader.GetDeviceSelector();
DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector);
foreach (DeviceInformation device in devices)
{
SmartCardReader reader = await SmartCardReader.FromIdAsync(device.Id);
reader.CardAdded += cardReader_CardAdded;
reader.CardRemoved += cardReader_CardRemoved;
}
}
private void cardReader_CardRemoved(SmartCardReader sender, CardRemovedEventArgs args)
{
}
private async void cardReader_CardAdded(SmartCardReader sender, CardAddedEventArgs args)
{
await HandleCard(args.SmartCard);
}
private async Task HandleCard(SmartCard card)
{
SmartCardProvisioning provisioning = await SmartCardProvisioning.FromSmartCardAsync(card);
SmartCardStatus status;
do
{
status = await provisioning.SmartCard.GetStatusAsync();
} while (status == SmartCardStatus.Shared);
}
答案 0 :(得分:0)
答案:我忘了在Package.appxmanifest
中的Capabilities下启用Proximity