【发布时间】:2014-08-24 08:10:04
【问题描述】:
我对此进行了很多搜索,但我不知道如何将文本字符串发送到 WindowsPhone 设备,但我可以从 WindowsPhone 到 Android。
这是我用来从 WindowsPhone 向 Android 发送消息的代码:
ProximityDevice device = ProximityDevice.GetDefault();
// Make sure NFC is supported
if (device!= null)
{
long Id = device.PublishMessage("Windows.MessageFromWindowsPhoneToAndroid", "Test");
}
我还在 C# 中找到了接收 NFC 消息的代码:
ProximityDevice device = ProximityDevice.GetDefault();
// Make sure NFC is supported
if (device!= null)
{
long Id = device.SubscribeForMessage ("Windows.NFCBeamMSGFromAndroid", messageReceived);
}
private void messageReceived(ProximityDevice sender, ProximityMessage message)
{
MessageBox.Show("Message Received");
Debug.WriteLine("Received from {0}:'{1}'", sender.DeviceId, message.DataAsString);
}
我测试了 WindowsPhone 的发送 NFC 消息功能,我在标签应用程序中看到了消息 ("MessageFromWindowsPhoneToAndroid")。
【问题讨论】:
标签: java c# android windows-phone-8 nfc