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

Native 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
Highlighted
Developer
Posts: 132
Registered: ‎11-06-2012
My Device: BlackBerry Passport
Accepted Solution

NFC Checking Problem

I have some problem when checking the connection of NFC, the first time it shows exactl, but it wrong in the second time. Please help me to fix it. Thanks.

 

This is the code:

 

    bool flag;
    nfc_result_t  result = nfc_connect();
    if(NFC_RESULT_SUCCESS == result){
        bool enabled;
        result = nfc_get_setting(NFC_SETTING_ENABLED, &enabled);
        if (enabled)
            flag = true;
    }
    else
        flag = false;
    return flag;

Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: NFC Checking Problem

[ Edited ]

Hi,

 

When IS the second time? Is it during the same execution? After sleep? Running the app again?

 

You generally only need to call nfc_connect() once, and it should be paired with an nfc_disconnect() when you no longer want to receive events.

 

The function itself has nothing to do with detecting a peer - it registers your code to receive events.

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 132
Registered: ‎11-06-2012
My Device: BlackBerry Passport

Re: NFC Checking Problem

I have a QTimer to run that function, 10 second/time. So I just have to disconnect at the end of check function right?

 

Regards,

Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: NFC Checking Problem

Can you explain your usecase a little? I'm not sure why you'd want to call that in a timer.

 

Have you seen this sample ? It exercises lots of nfc functionality...

--
Rob is no longer associated with BlackBerry.
Developer
Posts: 132
Registered: ‎11-06-2012
My Device: BlackBerry Passport

Re: NFC Checking Problem

I'm build an application to notificate the user what connect is on. Thanks for help.

One more question: Can I use code to automatic turn off the Wifi, Bluetooth and NFC?

Retired
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: NFC Checking Problem

There are some options;

 

have a look at 

    btapi/btdevice.h and wifi/wifi_service.h

--
Rob is no longer associated with BlackBerry.