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

Reply
Developer
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry
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
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

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
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry

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
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

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
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry

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
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10

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.