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

Examples of net.rim.device.api.io.nfc.readerwriter.ReaderWriterManager


                log("args[0] is an invalid type of Object");
                return Boolean.FALSE;
            }
        }
        try {
            ReaderWriterManager manager = ReaderWriterManager.getInstance();
            log("Unregister called for: " + typeNameFormat + " " + record_type);
            manager.removeNDEFMessageListener(typeNameFormat, record_type);
            _registry.unregister(typeNameFormat,record_type);
            result = true;
            log("NDEFMessageListener unregistered");
        } catch(Exception e) {
            log("Error trying to unregister",e);
View Full Code Here


                    + ") is of unsupported NDEF record type");
            return Boolean.FALSE;
        }
        try {
            log("last try");
            ReaderWriterManager manager = null;
            try {
                manager = ReaderWriterManager.getInstance();
            } catch (Exception e) {
                log("Failed in call to getInstance()");
                return Boolean.FALSE;
            }
            log("manager: " + manager);
            log("listener: " + _listener);
            log("typeNameFormat: " + typeNameFormat);
            log("record type: " + record_type);
            manager.addNDEFMessageListener(_listener, typeNameFormat,
                    record_type, true);
            result = true;
            log("NDEFMessageListener registered " + typeNameFormat + ":"
                    + record_type);
        } catch (Exception e) {
View Full Code Here

        startDetectionListener(_detectionListener);
    }

    protected void stopDetectionListener(NfcVirtDetectionListener detectionListener) {

        ReaderWriterManager nfcManager;

        Utilities.log("XXXX NfcVirtTarg about to remove Detection Listener");

        try {
            nfcManager = ReaderWriterManager.getInstance();
            /*
             * This is the converse of the call to register our interest in tags of a certain type.
             */
            nfcManager.removeDetectionListener(detectionListener);

            Utilities.log("XXXX NfcVirtTarg remove Detection Listener success");
            _screen.logEvent("info:Detection Listener removed");

        } catch(NFCException e) {
View Full Code Here

        }
    }

    protected void startDetectionListener(NfcVirtDetectionListener detectionListener) {

        ReaderWriterManager nfcManager;

        Utilities.log("XXXX NfcVirtTarg about to add Detection Listener");

        try {
            nfcManager = ReaderWriterManager.getInstance();
            nfcManager.addDetectionListener(detectionListener);

            Utilities.log("XXXX NfcVirtTarg add Detection Listener success");
            _screen.logEvent("info:Detection Listener added");

        } catch(NFCException e) {
View Full Code Here

        }
    }

    public void registerListener(NfcWriteNdefSmartTagListener nfcWriteNdefSmartTagListener) {

        ReaderWriterManager nfcManager;

        Utilities.log("XXXX NfcWriteNdefSmartTag about to add Detection Listener");

        try {
            nfcManager = ReaderWriterManager.getInstance();
            nfcManager.addDetectionListener(nfcWriteNdefSmartTagListener, new int[]{Target.NDEF_TAG});

            Utilities.log("XXXX NfcWriteNdefSmartTag add Detection Listener success");
            logEvent("Detection Listener added");

            rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(true));
View Full Code Here

        }
    }

    public void unRegisterListener(NfcWriteNdefSmartTagListener nfcWriteNdefSmartTagListener) {

        ReaderWriterManager nfcManager;
       
        Utilities.log("XXXX NfcWriteNdefSmartTag about to remove Detection Listener");
       
        try {
            nfcManager = ReaderWriterManager.getInstance();
            /*
             * This is the converse of the call to register our interest in
             * tags of a certain type.
            */
            nfcManager.removeDetectionListener(nfcWriteNdefSmartTagListener);
           
            Utilities.log("XXXX NfcWriteNdefSmartTag remove Detcetion Listener success");
            logEvent("Detection Listener removed");

            rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(false));
View Full Code Here

        return _mgr;
    }

    public void registerListener(Listener listener) {
//        unRegisterListener(); // just in case already registered
        ReaderWriterManager nfcManager;
        try {
            nfcManager = ReaderWriterManager.getInstance();
            nfcManager.addNDEFMessageListener(listener, NDEFRecord.TNF_EXTERNAL, "my.rim.com:myrecordtype", true);
            rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(true));
            Utilities.log("XXXX listener registered");
        } catch(NFCException e) {
            Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
        }
View Full Code Here

            Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
        }
    }

    public void unRegisterListener() {
        ReaderWriterManager nfcManager;
        try {
            nfcManager = ReaderWriterManager.getInstance();
            nfcManager.removeNDEFMessageListener(NDEFRecord.TNF_EXTERNAL, "my.rim.com:myrecordtype");
            Utilities.log("XXXX NfcReadNdefSmartTag remove NDEF Message Listener success");
            rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(false));
        } catch(NFCException e) {
            Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
        }
View Full Code Here

    /*
     * This registers with the NFC Reader Writer Manager indicating our interest in receiving notification when Smart Tags come
     * within range of the NFC antenna
     */
    public void registerListener(NfcReadNdefSmartTagListener listener) {
        ReaderWriterManager nfcManager;
        Utilities.log("XXXX NfcReadNdefSmartTag about to add NDEF Message Listener");
        try {
            nfcManager = ReaderWriterManager.getInstance();
            /*
             * An NDEF record always contains:
             *
             * * 3-bit TNF (Type Name Format) field: Indicates how to
             *   interpret the type field
             * * Variable length type: Describes
             *   the record format
             * * Variable length ID: A unique identifier
             *   for the record
             * * Variable length payload: The actual data
             *   payload
             *
             * The underlying record representation may be chunked across
             * several NDEF records when the payload is large.
             *
             * NDEFRecord.TNF_WELL_KNOWN - indicates that we are interested
             * in NDEF records of Type Name Format (TNF): "WELL_KNOWN"
             *
             * TNF_WELL_KNOWN included NFC RTD (Record Type Definitions)
             * types such as RTD_TEXT and RTD_URI meaning that they will
             * contain URIs or TEXT suitably encoded according to the NFC
             * RTD specification
             *
             * "Sp" identifies the record type as Smart Poster - so we're
             * only interested in being notified of Smart Poster records
             * that contain plain text or URIs
             *
             * The final parameter "true" identifies that the application
             * will be auto-started if it is not currently running when a
             * smart tag is brought within range of the NFC antenna.
             *
             * This setting is persistent across device power resets.
             *
             * When the application is restarted automatically on
             * presentation of a suitable smart tag to the device the
             * application will be re-started but it is necessary to
             * re-establish the NDEFMessageListener.
             *
             * Upon registering the listener again the tag that caused the
             * application to be re-started is immediately presented to the
             * listener making what is really a two stage process seem
             * seamless.
             *
             * It is important to re-start the listener within about 15 seconds
             * of the application being autostarted. Failure to do so will
             * result in the queued message being lost.
             *
             * There is also no way to determine if the application was
             * autostarted should you wish to automatically restart the
             * listener in this case. Of course you could always leave your
             * own tracks in the sand using the Persistent Store.
             *
             * This behaviour suggests that using the autostart option whilst
             * managing the setting up of the listener via the UI is a combination
             * that can lead to unexpected behaviour.
             *
             */
            nfcManager.addNDEFMessageListener(listener,
                    NDEFRecord.TNF_WELL_KNOWN, "Sp", true);
            Utilities.log("XXXX NfcReadNdefSmartTag add NDEF Message Listener success");
            rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(true));
            ListenerControlScreen.getInstance().setLed();

View Full Code Here

    /*
     * This unregisters with the NFC Reader Writer Manager We no longer want to be notified of Smart Tag events
     */
    public void unRegisterListener() {
        ReaderWriterManager nfcManager;
        Utilities.log("XXXX NfcReadNdefSmartTag about to remove NDEF Message Listener");
        try {
            nfcManager = ReaderWriterManager.getInstance();
            /*
             * This is the converse of the call to register our interest in tags of a certain type. It should identify the same
             * TNF and record type as when it was registered.
             */
            nfcManager.removeNDEFMessageListener(NDEFRecord.TNF_WELL_KNOWN, "Sp");
            Utilities.log("XXXX NfcReadNdefSmartTag remove NDEF Message Listener success");
            rts.replace(Constants.LISTENER_STATE_TOKEN, new Boolean(false));
            ListenerControlScreen.getInstance().setLed();
        } catch(NFCException e) {
            e.printStackTrace();
View Full Code Here

TOP

Related Classes of net.rim.device.api.io.nfc.readerwriter.ReaderWriterManager

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.