如何通过 nfc 共享图像并将其存储到数据库中?我查看了这个 网站,只设法创建对等连接。至于分享图片,我看到这篇文章并尝试运行演示,但我无法理解任何代码。有没有更简单的方法来做到这一点?
到目前为止我做了什么:
public ExchangeCard()
{
InitializeComponent();
ProximityDevice device = ProximityDevice.GetDefault();
// Make sure NFC is supported
if (device != null)
{
PeerFinder.TriggeredConnectionStateChanged += OnTriggeredConnectionStateChanged;
// Start finding peer apps, while making this app discoverable by peers
PeerFinder.Start();
}
}
StreamSocket _streamSocket;
void OnTriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgs args)
{
switch (args.State)
{
case TriggeredConnectState.Listening:
// Connecting as host
break;
case TriggeredConnectState.PeerFound:
// Proximity gesture is complete and user can pull their devices away. Remaining work is to
// establish the connection using a different transport, like TCP/IP or Bluetooth
break;
case TriggeredConnectState.Connecting:
// Connecting as a client
break;
case TriggeredConnectState.Completed:
// Connection completed, retrieve the socket over which to communicate
_streamSocket = args.Socket;
break;
case TriggeredConnectState.Canceled:
break;
case TriggeredConnectState.Failed:
// Connection was unsuccessful
break;
}
}