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
Contributor
bbthemelab
Posts: 47
Registered: ‎02-18-2011
My Device: Not Specified
Accepted Solution

Determine if user is connected to Wifi or not...

I am trying to create a form that will email me through my app, however, I only want to show it if the user is connected to wifi...

 

<script type="text/javascript">

var myJSONObject = {
    "data":{
        "hasCapability":[
            "network.wlan"
        ],
    }
}
   // Check if we have GPS capability
   if (blackberry.system.hasCapability("network.wlan")) {
		document.write('YOU ARE ON WIFI');	
   }
   	else { 
	document.write('YOU ARE NOT ON WIFI')
	}

</script>

 This is what I have right now.

 

This is my XML:

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="999.999.999">
<name>Test</name>
<authorId>bbthemelab</authorId>
<author>bbthemelab</author>
<autoOrients>false</autoOrients>
<feature id="blackberry.system" />
<rim:orientation mode="landscape" />
<icon rim:hover="false" src="appicon.png"/>
<content src="index.html"/>
</widget>

 

So, the apps kinda works. When I load it on my playbook, it reads YOU ARE ON WIFI. However, when I flip the switch on my wifi, it continues to read YOU ARE ON WIFI. I also tried to close the app and reload it, and it continue to reads YOU ARE ON WIFI.

 

 

Any help would be greatly appreciated!

Please use plain text.
Contributor
bbthemelab
Posts: 47
Registered: ‎02-18-2011
My Device: Not Specified

Re: Determine if user is connected to Wifi or not...

I should learn to keep trying and trying before I go ahead and come on here...

 

<script type="text/javascript">

var WiFiConnection = {
    "data":{
        "hasDataCoverage":true,
    }
}
	// Are we connected to Wifi?
   if (blackberry.system.hasDataCoverage()) {
		document.write('YOU ARE ON WIFI');	
   }

   // No? OH NO!
   	else { 
	document.write('YOU ARE NOT ON WIFI - SORRY!!!')
	}

</script>
<br /><br /><a href="javascript&colon;history.go(0);">Click here to refresh the page</a>

 I got it working... :smileywink:

Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780

Re: Determine if user is connected to Wifi or not...

Has anyone found a way to check that you have data coverage? And what kind of data coverage it is e.g. wifi,tethering,3g or bridge?
Please use plain text.