use of net.rim.device.api.io.nfc.readerwriter.ReaderWriterManager in project Samples-for-Java by blackberry.
the class NdefListenerManager method registerListener.
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());
}
}
use of net.rim.device.api.io.nfc.readerwriter.ReaderWriterManager in project Samples-for-Java by blackberry.
the class NdefListenerManager method unRegisterListener.
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());
}
}
use of net.rim.device.api.io.nfc.readerwriter.ReaderWriterManager in project Samples-for-Java by blackberry.
the class DetectionListenerManager method registerListener.
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));
} catch (NFCException e) {
e.printStackTrace();
Utilities.log("XXXX NfcWriteNdefSmartTag NFCException on register");
logEvent("Detection Listener add failed");
}
}
Aggregations