コード例 #1
0
 private void MessageReceivedHandler(ProximityDevice sender, ProximityMessage message)
 {
     try
     {
         using (var reader = DataReader.FromBuffer(message.Data))
         {
             reader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf16LE;
             string receivedString = reader.ReadString(reader.UnconsumedBufferLength / 2 - 1);
             Debug.WriteLine("Received message from NFC: " + receivedString);
             Url = receivedString;
             if (receivedString == "semc://liveware/A1/1/NT1/2/smarttags")
             {
                 tray.NFCRedDetected();
             }
             else if (receivedString == "semc://liveware/A1/1/NT1/3/smarttags")
             {
                 tray.NFCBlackDetected();
             }
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.StackTrace);
     }
 }