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
New Developer
Posts: 19
Registered: ‎12-06-2013
My Device: Q5
My Carrier: WIFI

Check the Internet

Hello

 

I want to check the Internet when you open the application.
I read many topics but does not explain what I want.

 

e.g. BlackBerry world.

 

 

Please step by step explanation.

 

Thanks.

Developer
Posts: 610
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

Re: Check the Internet

I would like to code snippet for this also. Help us include this functionality in our apps!

 

Developer
Posts: 1,177
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Check the Internet

This should work:

 

#include <bps/netstatus.h>

bool isConnected() {
    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 ) ) {
            switch ( netstatus_interface_get_type( details ) ) {
                case NETSTATUS_INTERFACE_TYPE_WIFI;
                case NETSTATUS_INTERFACE_TYPE_CELLULAR:
                    retVal = true;
            }
            netstatus_free_interface_details( &details );
        }
        bps_free( interface );
    }

    return retVal;
}

 



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.
New Developer
Posts: 19
Registered: ‎12-06-2013
My Device: Q5
My Carrier: WIFI

Re: Check the Internet

@greenback

 

Really we need

 

@greenmr

 

I've tried it nothing changes.

Developer
Posts: 1,177
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Check the Internet

All my code sample does is check the connection, it doesn't change anything. You'll have to add your own code to do that.


saad_A wrote:

@greenback

 

Really we need

 

@greenmr

 

I've tried it nothing changes.






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.
New Developer
Posts: 19
Registered: ‎12-06-2013
My Device: Q5
My Carrier: WIFI

Re: Check the Internet

@greenmr

 

Please any simple application of this.

Retired
Posts: 252
Registered: ‎08-17-2012
My Device: BlackBerry Z10 and Q10
My Carrier: Bell

Re: Check the Internet

Hi saad_A,

 

Here's how i would implement this behavior.

 

1. Check for WiFi connectivity using the following forum reply: http://supportforums.blackberry.com/t5/Native-Development/Connected-to-Wifi-check/m-p/2476989#M27155

 

2. And if not connected, use a dialog similar to the one shown in your screenshot. For how to use dialogs in your app, checkout this Cascades Sample app: https://github.com/blackberry/Cascades-Samples/tree/master/dialogs

 

3. On your dialog box, make the settings button invoke the settings app, where the user can turn on the Wifi. This is done using an invokation card of the Settings core app within your app. For the details on how to invoke the Settings app, checkout this link: http://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/settings.ht...

 

@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
Developer
Posts: 1,177
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Check the Internet

Just want to point out that the sample code in my earlier post in this thread implemented the solution to the first link you posted but was modified by the addition of a test for NETSTATUS_INTERFACE_TYPE_CELLULAR so that it tests for either a WiFi or carrier network connection. The original code in that thread only looks for a WiFi connection.


sabdelsayed wrote:

Hi saad_A,

 

Here's how i would implement this behavior.

 

1. Check for WiFi connectivity using the following forum reply: http://supportforums.blackberry.com/t5/Native-Development/Connected-to-Wifi-check/m-p/2476989#M27155

 

2. And if not connected, use a dialog similar to the one shown in your screenshot. For how to use dialogs in your app, checkout this Cascades Sample app: https://github.com/blackberry/Cascades-Samples/tree/master/dialogs

 

3. On your dialog box, make the settings button invoke the settings app, where the user can turn on the Wifi. This is done using an invokation card of the Settings core app within your app. For the details on how to invoke the Settings app, checkout this link: http://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/settings.ht...

 






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.