Examples of NDEFMessage


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

                        // implementation...
                    }
                } else if (typeNameFormat == NDEFRecord.TNF_MEDIA) {
                    mergeInto(jsonRecord, parseMediaRecord(records[j]));
                } else if (typeNameFormat == NDEFRecord.TNF_EXTERNAL) {
                    NDEFMessage message = new NDEFMessage(
                            records[j].getPayload());
                    mergeInto(jsonRecord, parseMessage(message));
                }

                if (!jsonRecord.has(Constants.NDEF_PAYLOAD64)) {
View Full Code Here

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

        }
        return result;
    }

    public void run() {
        NDEFMessage message = null;
        synchronized (_messages) {
            message = (NDEFMessage) _messages.elementAt(_messages.size() - 1);
            _messages.removeElementAt(_messages.size() - 1);
        }

        JSONObject toUse;
        try {
            toUse = parseMessage(message);
            try {
                _js_bridge.useNDEFMessage(
                        toUse.getInt(Constants.NDEF_TYPE_NAME_FORMAT),
                        toUse.getString(Constants.NDEF_TYPE), toUse.toString());
            } catch (JSONException j) {
                log("Could not send object back to event handler", j);
            }
        } catch (Exception e) {
            String record_type = "?";
            int typeNameFormat = NDEFRecord.TNF_WELL_KNOWN;
            try {
                NDEFRecord[] records = message.getRecords();
                if (records.length > 0) {
                    record_type = records[0].getType();
                    typeNameFormat = records[0].getTypeNameFormat();
                }
            } catch (Exception toIgnore) {
View Full Code Here

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

        // if(true)
        // throw new NFCException("Fictitious NFC problem");

        log("Recognised a Smart Poster Message");
        // try {
        NDEFMessage smartPosterMessage = new NDEFMessage(record.getPayload());
        NDEFRecord[] spRecords = smartPosterMessage.getRecords();
        int numSpRecords = spRecords.length;
        log("Parsing smartposter #records=" + numSpRecords);

        if (numSpRecords > 0) {
            log("Parsing Smart Poster Message");
View Full Code Here

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

    public NDEFMessage[] buildNDEFMessages() {
        Utilities.log("XXXX NfcSnepResponder Received Push Request");
        _screen.logEvent("rcvd:Received Push Request");

        NDEFMessage[] listOfNdefMessages = null;
        NDEFMessage myNdefMessage;

        try {
            Utilities.log("XXXX NfcSnepResponder Constructing Media Type: " + Constants.VCARD_MIME_TYPE);
            _screen.logEvent("send:Constructing Media Type: " + Constants.VCARD_MIME_TYPE);
View Full Code Here

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

    public NDEFMessage[] buildNDEFMessages() {

        Utilities.log("XXXX NfcSender sending ProtocolMessage:" + _message);

        NDEFMessage[] ndef_messages = null;
        NDEFMessage game_message;

        try {

            byte[] payload = _message.marshall();
            Utilities.log("XXXX NfcSender sending payload 0x" + ByteArrayUtilities.byteArrayToHex(payload));           
View Full Code Here

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

        Utilities.log("XXXX Writing URI tag");
        NDEFTagConnection tagConnection = null;
        String uri = (String) _tag_attrs.get(Constants.TAG_ATTRIBUTE_URI);

        try {
            NDEFMessage uriNdefMessage = NDEFMessageUtils.createUriNDEFMessage(uri);
            tagConnection = (NDEFTagConnection) Connector.open(target_uri);
            tagConnection.write(uriNdefMessage);
            Utilities.log("XXXX NfcWriteNdefSmartTagListener URI Tag written successfully");
            _screen.logEvent("Custom Tag written successfully");
        } catch(Exception e) {
View Full Code Here

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

        Utilities.log("XXXX Writing Text tag");
        NDEFTagConnection tagConnection = null;
        String text = (String) _tag_attrs.get(Constants.TAG_ATTRIBUTE_TEXT);

        try {
            NDEFMessage externalNdefMessage = NDEFMessageUtils.createTextNDEFMessage(text, URL_TEXT_LOCALE);
            tagConnection = (NDEFTagConnection) Connector.open(target_uri);
            tagConnection.write(externalNdefMessage);
            Utilities.log("XXXX NfcWriteNdefSmartTagListener Text Tag written successfully");
            _screen.logEvent("Custom Tag written successfully");
        } catch(Exception e) {
View Full Code Here

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

        Utilities.log("XXXX domain:" + domain);
        Utilities.log("XXXX type:" + type);
        Utilities.log("XXXX content:" + content);

        try {
            NDEFMessage externalNdefMessage = NDEFMessageUtils.createExternalTypeMessage(domain, type,
                    content.getBytes("US-ASCII"));
            tagConnection = (NDEFTagConnection) Connector.open(target_uri);
            tagConnection.write(externalNdefMessage);
            Utilities.log("XXXX NfcWriteNdefSmartTagListener Custom Tag written successfully");
            _screen.logEvent("Custom Tag written successfully");
View Full Code Here

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

        String willWriteMsg = "Writing Smart Poster Tag " + _screen.getTagDetails() + ",Language: " + URL_TEXT_LOCALE;

        _screen.logEvent(willWriteMsg);

        try {
            NDEFMessage smartPosterTag = createSmartPosterTag();
            tagConnection = (NDEFTagConnection) Connector.open(target_uri);
            tagConnection.write(smartPosterTag);
            Utilities.log("XXXX NfcWriteNdefSmartTagListener SP Tag written successfully");
            _screen.logEvent("SP tag written successfully");
        } catch(NFCException e) {
View Full Code Here

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

        // do this the old school way!

        String uri = (String) _tag_attrs.get(Constants.TAG_ATTRIBUTE_URI);
        String text = (String) _tag_attrs.get(Constants.TAG_ATTRIBUTE_TEXT);

        NDEFMessage rootMessage = new NDEFMessage(); // (SP (TEXT, URL) message
        NDEFMessage ndefMessage = new NDEFMessage(); // (TEXT, URL) message

        NDEFRecord rootRecord = new NDEFRecord(); // Smart Poster Record
        NDEFRecord tagTitleRecord = new NDEFRecord(); // Tag Title TEXT record
        NDEFRecord tagUrlRecord = new NDEFRecord(); // Tag URL record

        ByteArrayOutputStream titlePayload = new ByteArrayOutputStream(); // to build title
        ByteArrayOutputStream urlPayload = new ByteArrayOutputStream(); // to build URL

        /*
         * ================ Record 0 ===========================================
         *
         * This is the NDEF record that represents the title associated with the URL that will the URL part of the Smart Poster
         * Tag
         */
        titlePayload.write((byte) URL_TEXT_LOCALE.length()); // status byte: character encoding indicator bit plus length of
                                                             // locale language field
        titlePayload.write(URL_TEXT_LOCALE.getBytes("US-ASCII")); // locale language
        /*
         * This is the text to be associated with the Smart Poster Tag
         */
        titlePayload.write(text.getBytes("UTF-8")); // Text
        titlePayload.flush();
        /*
         * Construct the record itself
         */
        tagTitleRecord.setId("0"); // record Id
        tagTitleRecord.setType(NDEFRecord.TNF_WELL_KNOWN, "T"); // It's TEXT type
        tagTitleRecord.setPayload(titlePayload.toByteArray()); // construct the record

        /*
         * ================ Record 1 ===========================================
         *
         * This is the NDEF record that represents the URL associated with the title that will the Text part of the Smart Poster
         * Tag
         */
        urlPayload.write((byte) 0x01); // coded abbreviation for "http://www."
        urlPayload.write(uri.getBytes()); // The rest of the URL
        urlPayload.flush();
        /*
         * Construct the record itself
         */
        tagUrlRecord.setId("1"); // record Id
        tagUrlRecord.setType(NDEFRecord.TNF_WELL_KNOWN, "U"); // It's a URL(I) type
        tagUrlRecord.setPayload(urlPayload.toByteArray()); // construct the record

        /*
         * ================ Construct an NDEF MEssage ==========================
         *
         * This NDEF Message comprises the Title and URL records (TEXT, URL)
         */
        ndefMessage.setRecords(new NDEFRecord[] { tagTitleRecord, tagUrlRecord });

        /*
         * ================ Wrap the message as a Smart Poster Tag ============
         *
         * What we have now is a single NDEF message with two records, a URL and some text associated with it. We now need to make
         * that into a Smart poster Tag which is a well known type: "Sp"
         */
        rootRecord.setType(NDEFRecord.TNF_WELL_KNOWN, "Sp"); // Smart Poster Type
        rootRecord.setPayload(ndefMessage.getBytes()); // construct the record

        /*
         * ================ Construct an NDEF MEssage ==========================
         *
         * This NDEF message contains a single record encoding the Smart Poster Tag
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.