Package net.rim.device.api.io.nfc.ndef

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


    /**
     * 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

        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

TOP

Related Classes of net.rim.device.api.io.nfc.ndef.NDEFMessage

Copyright © 2018 www.massapicom. 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.