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

Web and WebWorks Development

Reply
Regular Contributor
kokoman
Posts: 76
Registered: ‎11-13-2012
My Device: curve 9300

network access

Hello peeps, am trying to achieve a concept, when i try access my app I want it to display an rror message when there is no active network, and the app be closed, how can I achieve that.
BlackBerry Development Advisor
rcraigbarnes
Posts: 40
Registered: ‎01-11-2013
My Device: BlackBerry Z10

Re: network access

Not sure what OS you are using, but BB10 has the connection object that you can query/listen to for connection status:

 

https://developer.blackberry.com/html5/apis/blackberry.connection.html

--
Website Relations - Web Technologies

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
Regular Contributor
yamafarooq
Posts: 65
Registered: ‎01-03-2013
My Device: 9810

Re: network access

The easy way will be to use Phonegap, you can simply find which type of newtork is connect and what is the states of the connection.  To check the states of connection add the function checkConnection in your javascript,

function checkConnection() {
    var networkState = navigator.network.connection.type;

    var states = {};
    states[Connection.UNKNOWN]  = 'Unknown connection';
    states[Connection.ETHERNET] = 'Ethernet connection';
    states[Connection.WIFI]     = 'WiFi connection';
    states[Connection.CELL_2G]  = 'Cell 2G connection';
    states[Connection.CELL_3G]  = 'Cell 3G connection';
    states[Connection.CELL_4G]  = 'Cell 4G connection';
    states[Connection.NONE]     = 'No network connection';

    alert('Connection type: ' + states[networkState]);
}
// call the function in place you want "checkConnection();"
-----
Please press the like button to thank the user that helped you.
Accept as a solution if it solved the problem.
Cheers
Regular Contributor
kokoman
Posts: 76
Registered: ‎11-13-2012
My Device: curve 9300

Re: network access

Thanks
Regular Contributor
yamafarooq
Posts: 65
Registered: ‎01-03-2013
My Device: 9810

Re: network access

[ Edited ]

Your welcome, can please press like if it was helpful and accept as solution

-----
Please press the like button to thank the user that helped you.
Accept as a solution if it solved the problem.
Cheers