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
simon_hain
Posts: 16,209
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
Accepted Solution

Reliable network status/coverage?

I am trying to react on changes of the network status.

 

QNetworkAccessmanager seemed the solution, but a quick search showed that you have to use QNetworkConfigurationManager instead.

 

The onlineStateChanged signal seems to be very unrealiable though. I receive it consistently when the connectivity drops (i enable airplane mode), but when it recovers (i disable airplane mode) i do not get the signal.

When i switch the network off again i get the signal with online=true followed by a second call with online=false about 2 seconds later.

I have also tried to subscribe to configurationAdded/Changed/Removed events, but those did not help either.

 

In this post the bps methods are mentioned, can somebody give me a small snippet how i subscribe to the bps network changes? Maybe they are more reliable than the Qt API.

 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
simon_hain
Posts: 16,209
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Reliable network status/coverage?

That was easier than expected, i followed the directions in the bps API and subscribed to network events where i use netstatus_get_availability()

 

bps_initialize();
subscribe(netstatus_get_domain());
netstatus_request_events(0);

 

void Class::event(bps_event_t *event)
{
    // Handle events
    if (bps_event_get_domain(event) == netstatus_get_domain()) {
        qDebug() << "network event";
        bool netAvail = false;
        netstatus_get_availability(&netAvail);
        qDebug() << "bps network availability" << netAvail;
    }
}

 Strange enough the QNetworkConfigurationManager event is now reported correctly as well, maybe it did not get the events from bps and my subscription fixed it.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
MatthewGeomax
Posts: 39
Registered: ‎02-06-2013
My Device: Developer - BB10 Dev B

Re: Reliable network status/coverage?

I was looking for exactly this, and having the same issues as you with the stock Q implementations. Thanks!

Please use plain text.