Пример #1
0
 public static NFCManager getInstance()
 {
     if (singleton == null) {
     singleton = new NFCManager();
       }
       return singleton;
 }
Пример #2
0
 public static NFCManager getInstance()
 {
     if (singleton == null)
     {
         singleton = new NFCManager();
     }
     return(singleton);
 }
Пример #3
0
        // ------------------------------------------
        //  PRIVATE READER
        // ------------------------------------------

        private void MessageReceivedHandler(ProximityDevice sender, ProximityMessage message)
        {
            // Parse raw byte array to NDEF message
            var rawMsg      = message.Data.ToArray();
            var ndefMessage = NdefMessage.FromByteArray(rawMsg);

            // Loop over all records contained in the NDEF message
            foreach (NdefRecord record in ndefMessage)
            {
                Console.WriteLine("Record type: " + Encoding.UTF8.GetString(record.Type, 0, record.Type.Length));

                // Check the type of each record - handling a Smart Poster in this example
                var specializedType = record.CheckSpecializedType(true);

                // Convert and extract Smart Poster info
                if (specializedType == typeof(NdefSpRecord))
                {
                    var    spRecord = new NdefSpRecord(record);
                    String msg      = "URI: " + spRecord.Uri + "\n"
                                      + "Titles: " + spRecord.TitleCount() + "\n"
                                      + "1. Title: " + spRecord.Titles[0].Text + "\n"
                                      + "Action set: " + spRecord.ActionInUse();
                    NFCManager.getInstance().Alert(msg);
                }

                // Convert and extract URI record info
                else if (specializedType == typeof(NdefUriRecord))
                {
                    var    uriRecord = new NdefUriRecord(record);
                    String msg       = "URI: " + uriRecord.Uri + "\n";
                    NFCManager.getInstance().Alert(msg);
                    NFCManager.getInstance().SendRequest(uriRecord.Uri);
                }

                // Convert and extract Mailto record info
                else if (specializedType == typeof(NdefMailtoRecord))
                {
                    var    mailtoRecord = new NdefMailtoRecord(record);
                    String msg          = "Address: " + mailtoRecord.Address + "\n"
                                          + "Subject: " + mailtoRecord.Subject + "\n"
                                          + "Body: " + mailtoRecord.Body;
                    NFCManager.getInstance().Alert(msg);
                }
            }
        }
Пример #4
0
 void Request_Click(object sender, EventArgs e)
 {
     NFCManager.getInstance().SendURL = request.Checked;
 }
Пример #5
0
 void Alert_Click(object sender, EventArgs e)
 {
     NFCManager.getInstance().ShowAlert = alert.Checked;
 }
Пример #6
0
 private void MessageWrittenHandler(ProximityDevice sender, long messageid)
 {
     // Stop publishing the message
     StopPublishingMessage(false);
     NFCManager.getInstance().Alert("Message Written", true);
 }