Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
sanika_sudhalkar
Posts: 22
Registered: ‎09-14-2010
My Device: Not Specified
Accepted Solution

Starting the application automatically on tag detection, when using the DetectionListener.

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.

BlackBerry Development Advisor
jomurray
Posts: 133
Registered: ‎09-06-2010
My Device: Z30

Re: Starting the application automatically on tag detection, when using the DetectionListener.

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)
---------------------------------------
Please refrain from posting new questions in solved threads.
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Found a bug? Report it here
Follow me on Twitter @jcmrim
Contributor
sanika_sudhalkar
Posts: 22
Registered: ‎09-14-2010
My Device: Not Specified

Re: Starting the application automatically on tag detection, when using the DetectionListener.

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?

BlackBerry Development Advisor
jomurray
Posts: 133
Registered: ‎09-06-2010
My Device: Z30

Re: Starting the application automatically on tag detection, when using the DetectionListener.

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/net/rim/device/api/io/nfc/readerwriter/Target.htm...) or use target.getUri() which can then be used to open a connection to the tag to read data using, say, APDUs via the tranceive() method.

---------------------------------------
Please refrain from posting new questions in solved threads.
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Found a bug? Report it here
Follow me on Twitter @jcmrim