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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
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.

Retired
Posts: 170
Registered: ‎09-06-2010
My Device: None
My Carrier: None

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)
Contributor
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?

Highlighted
Retired
Posts: 170
Registered: ‎09-06-2010
My Device: None
My Carrier: None

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.