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
Posts: 24
Registered: ‎10-31-2012
My Device: Dev Alpha B
My Carrier: COMPE
Accepted Solution

How to get the wifi status?

Hello,

 

I need to know when the phone is connected to a wifi network.

 

Thanks,

__
Helped you? Like me.
Developer
Posts: 180
Registered: ‎12-09-2011
My Device: 9360, BB10
My Carrier: Aircel

Re: How to get the wifi status?

Developer
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: How to get the wifi status?

[ Edited ]

I think this is what you want

 

https://developer.blackberry.com/native/documentation/cascades/device_comm/networking/wrapping_up.ht...

 

NETSTATUS_INTERFACE_TYPE_WIFI

 

:Punk:



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
BlackBerry Development Advisor
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: How to get the wifi status?

Hi laairoy,

 

Here are some forum posts where this question has been addressed before. Hope it helps.

 

http://supportforums.blackberry.com/t5/Native-Development/Connected-to-Wifi-check/m-p/2476989#M27155

http://supportforums.blackberry.com/t5/Native-Development/Data-network-availibility-signal/m-p/24770...

http://supportforums.blackberry.com/t5/Native-Development/How-to-check-whether-internet-is-enbled-or...

@SamarAbdelsayed

Did this answer your question? Please accept post as solution.
Please refrain from posting new questions in solved threads.
Found a bug? Report it using the Issue Tracker
Contributor
Posts: 26
Registered: ‎10-15-2013
My Device: Hidden
My Carrier: Hdden
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to get the wifi status?

@worriers that is a link to a Java solution this is the Native forum, please desist from adding to threads with duplicate or non-relevant information, thanks.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: How to get the wifi status?

This is the best class for check which type of connection is actually use

 

https://developer.blackberry.com/native/reference/core/com.qnx.doc.bps.lib_ref/com.qnx.doc.bps.lib_r...

 

This is example:

https://developer.blackberry.com/native/documentation/cascades/device_comm/networking/wrapping_up.ht...

 

Yes, QNetworkInterface can also be used, but i think is only for WIFI (online/offline) status. Better way is check online/offline status with netstatus API, because you can check wifi, gprs etc...



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 1,004
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: How to get the wifi status?

The only WiFi related info in these links are for WiFiDirect, which is not relevant to this question regarding regular WiFi connections.

 


hemant_sain wrote:

Please go through the WiFi api below are the link:

 

https://developer.blackberry.com/native/reference/cascades/device_and_communication.html

 

https://developer.blackberry.com/native/reference/cascades/bb__device__wifidirect.html






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 1,004
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: How to get the wifi status?

I have been all over the Internet and back looking for a way to determine not only if WiFi is switched on, but also if it is connected. Every "solution" I found online actually only reported if WiFi was up or down, not its connection state. However, I was able to adapt a code suggestion from  to do exactly what I needed. Here is the function I created:

 

 

#include <bps/netstatus.h>

bool onWiFi() {
    bool retVal = false;
    char* interface;

    if ( BPS_SUCCESS == netstatus_get_default_interface( &interface ) ) {
        netstatus_interface_details_t* details = NULL;
        if ( BPS_SUCCESS == netstatus_get_interface_details( interface, &details ) ) {
            retVal = ( netstatus_interface_get_type( details ) == NETSTATUS_INTERFACE_TYPE_WIFI );
            netstatus_free_interface_details( &details );
        }
        bps_free( interface );
    }

    return retVal;
}

 

This function returns true ONLY if WiFi is turned on AND connected as the default interface.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 46
Registered: ‎12-15-2014
My Device: Z10
My Carrier: Vodafone

Re: How to get the wifi status?

worked for me

 

thanks :smileyhappy: