This article is a mirror article of machine translation, please click here to jump to the original article.

View: 8432|Reply: 2

Sense the bank card through Windows Phone

[Copy link]
Posted on 12/6/2014 12:02:20 AM | | | |

I bought a Nokia lumia 930 mobile phone a while ago, and in the past few days I learned that there is a tall function called NFC, which can read bank cards, all-in-one cards and other information.
I put my bank card on my phone, and the phone beeped, but nothing was shown. Baidu suddenly found that only Alipay wallets on Android have this function, so it researched and wrote a small program. As shown below

This program is very simple, the bank card will output "the bank card is coming" when it is pasted on the mobile phone, and the "bank card is gone" when it leaves.

The implementation process is simple and follows:

Create an empty windows phone project and add three class members and two event functions to the MainPage.


[mw_shl_code=csharp,true] Windows::Foundation::EventRegistrationToken m_arrivedToken;
Windows::Foundation::EventRegistrationToken m_departedToken;
Windows::Networking::Proximity::ProximityDevice^ m_proximityDevice;

void DeviceArrived(Windows::Networking::Proximity::ProximityDevice^ device);
void DeviceDeparted(Windows::Networking::Proximity::ProximityDevice^ device); [/mw_shl_code]

Then get the default NFC device in the constructor of MainPage, register two events in OnNavigatedTo, which are used to respond to the event of the bank card approaching the mobile phone and leaving, so that when the event is triggered, the DeviceArrived and DeviceDeparted processes will be called, and the process will simply execute an output log. over


[mw_shl_code=csharp,true] MainPage::MainPage()
{
InitializeComponent();
m_proximityDevice = ProximityDevice::GetDefault();
}

void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
{
(void) e; Unused parameters
if (this->m_proximityDevice)
{
m_arrivedToken = m_proximityDevice->DeviceArrived += ref new DeviceArrivedEventHandler(this, &MainPage::DeviceArrived, CallbackContext::Same);
m_departedToken = m_proximityDevice->DeviceDeparted += ref new DeviceDepartedEventHandler(this, &MainPage::DeviceDeparted, CallbackContext::Same);
}
}

void MainPage::DeviceArrived(ProximityDevice^ device)
{
ErrorText->Text += "The bank card is coming! \r\n”;
}

void MainPage::DeviceDeparted(ProximityDevice^ device)
{
ErrorText->Text += "The bank card is gone! \r\n”;
}[/mw_shl_code]

In this way, such a program is completed, and the next step is to read the information. . .
If you have time, continue to study it again and read out the bank card data.




Previous:Fix the issue of "Error 103 (net::ERR_CONNECTION_ABORTED): Unknown Error" in Google Chrome
Next:[VB] Anonymous pipeline implements CMD echo
Posted on 12/7/2014 5:24:39 PM |
Reading and posting back is a virtue
Posted on 12/7/2014 11:22:11 PM |
930.。。。。。。。。。。。。。。 Mine is
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com