04-20-2012 03:39 AM
In my application, I need to read NDEF records, and open the application if it isn't opened already. Earlier, I was using the NDEFMessageListener for the same, and setting the "autoStart" value to true. This did the job for me.
Now, we also need to fetch the UID of the tag, the value of which can only be fetched using the DetectionListener. Now the problem is, when I register the DetectionListener, there's no property like "autoStart" provided. Even if i manage to get the application opened somehow, when the tag is detected, the Blackberry Smart Tags application's popup comes, even when my application is running, and processing the tag's information.
I want to somehow stop the Blackberry Smart tags application from opening, when my application is present on the device.
Currently, I am achieving this by registering both the NDEFMessageListener and DetectionListener, but since the
public void addNDEFMessageListener(NDEFMessageListener listener, int typeNameFormat, String recordType, boolean autoStart)
method is deprecated in the 7.1 OS, and since registering one listener should do the job, I wanted to find a way to do away with the NDEFMessageListener alltogether.
Solved! Go to Solution.
04-25-2012 10:37 AM
The method with signature below which is part of 7.1 is effectively the same as the one you are using in 7.0 with the "autoStart" parameter that has been deprecated. In 7.1 it implicitly assumes that the application wants to be autostarted by default. The functionality that has effectively been removed by the deprecation is to allow autoStart to be set to false.
Yes, I understand what you're saying about wanting to get access to information like the UID which is part of the ATR from the tag when detected. You do need to use DetectionListener to access this.
public void addNDEFMessageListener(NDEFMessageListener listener, int typeNameFormat, String recordType)
04-25-2012 10:45 AM
So then, the way I understand it, I will have to use both the listeners, even if I need to use just the DetectionLisetener, if I want to auto start my application. Is that correct?
04-26-2012 06:47 AM
That's correct.To communicate with the tag to obtain information other than the NDEF payload presented via onNDEFMessageDetected(NDEFMessage msg) you need to obtain the target returned through onTargetDetected(Target target) method of the DetectionListener interface. You can then use either target.getProperties() to enumerate the list of properties associated with the target ( http://www.blackberry.com/developers/docs/7.1.0api