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
pushkaraj9009
Posts: 72
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

NFC status

how to get the correct status of nfc in cascades bb 10...i tried many functions from nfc.h,but none of them gave me the desired result....Basically i just want to show a label as TRUE if nfc is On,else FALSE if nfc is Off......Please help

 

Thanks 

Please use plain text.
Developer
DrShavargo
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: NFC status

If you follow the developer guide on NFC, you'll find there is no on or off mode for the NFC Service. As shown here, you use an invocationManager to invoke use of the NSC. It works similarly to how you invoke the Phone in your app. The phone has no on/off mode; the only thing controlling wether signals are being sent or recieved is Airplane mode.

 

This is an oversimplification, but to sum up, NCF is "on" when you invoke it, and "off" when you release it.

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Please use plain text.
Developer
pushkaraj9009
Posts: 72
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: NFC status

I have already used  invocation to On/Off the NFC.....i just want to show its status as a label in my application.

Also there is one application named "Battery Lover" that uses somewhat similar thing....it reflects the change in status      

of NFC...

Please use plain text.
Developer
DrShavargo
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: NFC status

Well, simply put, when you invoke it, change the text of the label manually through onCreationCompleted() or via your own function, by calling yourLabel.text = "On". Do the same for "Off". I can't see any other way of doing it...

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Please use plain text.
Developer
pushkaraj9009
Posts: 72
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: NFC status

yes we can do that way......but this will be restricted only for my app....i want it like if the user turn off the nfc from outside my app,still it should reflect it in my app....like getting a signal of state changed.....

 

Thanks

Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: NFC status

Hi,

 

To see if NFC is on / off:

 

	result = nfc_connect();
	if (result != NFC_RESULT_SUCCESS) {
		// do something
	}

	result = nfc_get_setting(NFC_SETTING_ENABLED, &value);
	if (result == NFC_RESULT_SUCCESS) {
		qDebug() << "NFC is " << (value ? "on" : "off");
	} else {
		qDebug() << "Could not query value???";
	}

 

--
Rob is no longer associated with BlackBerry.
Please use plain text.
Developer
pushkaraj9009
Posts: 72
Registered: ‎06-20-2013
My Device: Blackberry 10
My Carrier: idea

Re: NFC status

thanks...:smileyhappy:

wil surely try with this.....

Please use plain text.
Developer
tanphat1412
Posts: 123
Registered: ‎11-06-2012
My Device: BlackBerry
My Carrier: Mobifone

Re: NFC status

This is the way I check the nfc status. Hope it can help you.

 

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

 

Please use plain text.