Examples of NdefMessage


Examples of net.rim.device.api.io.nfc.ndef.NDEFMessage

                 * If we recognise this as a Smart Tag Type "Sp"
                 */
                if("Sp".equals(records[j].getType())) {
                    Utilities.log("XXXX NfcReadNdefSmartTagUpdate recognised a Smart Poster Message");
                    try {
                        NDEFMessage smartPosterMessage = new NDEFMessage(records[j].getPayload());
                        NDEFRecord[] spRecords = smartPosterMessage.getRecords();
                        int numSpRecords = spRecords.length;
                        Utilities.log("XXXX NfcReadNdefSmartTagUpdate in runnable #records=" + numSpRecords);

                        if(numSpRecords > 0) {
                            Utilities.log("XXXX NfcReadNdefSmartTagUpdate processing Smart Poster Message");
View Full Code Here

Examples of net.rim.device.api.io.nfc.ndef.NDEFMessage

    /**
     * Starts emulating an NDEF tag with hardcoded payloads
     */
    public void startNDEFEmulation() {
        // Create the NDEFMessage that will contain the NDEFRecords
        final NDEFMessage ndefMessage = new NDEFMessage();

        // Begin creating the NDEFRecords with "text/plain" payloads
        final NDEFRecord rec1 = new NDEFRecord();
        rec1.setId("1");

        try {
            rec1.setType(NDEFRecord.TNF_MEDIA, "text/plain");
        } catch (final NFCException e) {
            _screen.add(new LabelField("Error: " + e.toString()));
        }

        rec1.setPayload("I am the 1st payload".getBytes());

        final NDEFRecord rec2 = new NDEFRecord();
        rec2.setId("2");

        try {
            rec2.setType(NDEFRecord.TNF_MEDIA, "text/plain");

        } catch (final NFCException e) {
            _screen.add(new LabelField("Error: " + e.toString()));
        }

        rec2.setPayload("I am the 2nd payload".getBytes());
        ndefMessage.setRecords(new NDEFRecord[] { rec1, rec2 });

        // Create the VirtualNDEFTag to be emulated
        _ndefVirtualTarget =
                new VirtualNDEFTag(ndefMessage, new VirtualNDEFTagListener(
                        _screen));
View Full Code Here

Examples of net.rim.device.api.io.nfc.ndef.NDEFMessage

        final StringBuffer sb = new StringBuffer();

        // Try to open a connection to the NDEF tag and read its content
        try {
            c = (NDEFTagConnection) Connector.open(uri);
            final NDEFMessage ndefMessage = c.read();
            final NDEFRecord[] ndefRecords = ndefMessage.getRecords();

            // Go through all the NDEFRecords in the NDEFMessage
            for (int i = 0; i < ndefMessage.getNumberOfRecords(); i++) {
                final String type = ndefRecords[i].getType();
                sb.append("Type for record ");
                sb.append((i + 1));
                sb.append(" : ");
                sb.append(type);
View Full Code Here

Examples of org.nfctools.ndef.NdefMessage

    TypeLengthValueReader reader = new TypeLengthValueReader(new TagInputStream(memoryLayout, readerWriter));

    while (reader.hasNext()) {
      Tlv tlv = reader.next();
      if (tlv instanceof NdefMessageTlv) {
        NdefMessage ndefMessage = decoder.decode(((NdefMessageTlv)tlv).getNdefMessage());
        for (Record record : decoder.decodeToRecords(ndefMessage)) {
          System.out.println(record);
        }
      }
    }
View Full Code Here

Examples of org.nfctools.ndef.NdefMessage

    lastReadRecords = new ArrayList<Record>();
    NdefMessageDecoder ndefMessageDecoder = NdefContext.getNdefMessageDecoder();
    while (reader.hasNext()) {
      Tlv tlv = reader.next();
      if (tlv instanceof NdefMessageTlv) {
        NdefMessage ndefMessage = ndefMessageDecoder.decode(((NdefMessageTlv)tlv).getNdefMessage());
        for (Record record : ndefMessageDecoder.decodeToRecords(ndefMessage)) {
          lastReadRecords.add(record);
        }
      }
    }
View Full Code Here

Examples of org.nfctools.ndef.NdefMessage

      List<Record> records = new ArrayList<Record>();

      while (lengthValueReader.hasNext()) {
        Tlv tlv = lengthValueReader.next();
        if (tlv instanceof NdefMessageTlv) {
          NdefMessage ndefMessage = ndefMessageDecoder.decode(((NdefMessageTlv)tlv).getNdefMessage());
          for (Record record : ndefMessageDecoder.decodeToRecords(ndefMessage)) {
            records.add(record);
          }
        }
      }
View Full Code Here

Examples of org.nfctools.ndef.NdefMessage

  @Override
  public WellKnownRecord decodePayload(byte[] payload, NdefMessageDecoder messageDecoder) {
    byte configurationByte = payload[0];

    NdefMessage payloadNdefMessage = messageDecoder.decode(payload, 1, payload.length - 1);

    GcTargetRecord target = null;
    GcActionRecord action = null;
    GcDataRecord data = null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.