Beispiel #1
0
        /// <summary>
        /// Inserts a record at the index into the NDEF message.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>Whether inserting the record succeeded.</returns>
        /// <param name="index">The index of a record ( starts from 0 ).</param>
        /// <param name="record">The NfcNdefRecord object that will be appended into the NDEF message.</param>
        public bool InsertRecord(int index, NfcNdefRecord record)
        {
            bool isSuccess = true;

            int ret = Interop.Nfc.NdefMessage.InsertRecord(_messageHandle, index, record.GetHandle());

            if (ret != (int)NfcError.None)
            {
                Log.Error(Globals.LogTag, "Failed to insert record, Error - " + (NfcError)ret);
                isSuccess = false;
            }
            else
            {
                _recordList.Add(record);
            }

            return(isSuccess);
        }
Beispiel #2
0
        /// <summary>
        /// Gets a record by the index.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns>The NfcNdefRecord object.</returns>
        /// <param name="index">The index of a record ( starts from 0 ).</param>
        public NfcNdefRecord GetRecord(int index)
        {
            IntPtr        recordHandle;
            NfcNdefRecord recordObject = null;

            int ret = Interop.Nfc.NdefMessage.GetRecord(_messageHandle, index, out recordHandle);

            if (ret != (int)NfcError.None)
            {
                Log.Error(Globals.LogTag, "Failed to remove record, Error - " + (NfcError)ret);
            }

            foreach (NfcNdefRecord recordElement in _recordList)
            {
                if (recordElement.GetHandle() == recordHandle)
                {
                    Log.Debug(Globals.LogTag, "Find record handle");
                    recordObject = recordElement;
                    break;
                }
            }

            return(recordObject);
        }