23663

How to detect network in Blackberry 10 Dev Alpha Simulator using qnx.net.NetworkManager on Air SDK

I'm trying to detect internet connection of the simulator using this code

if ( NetworkManager.networkManager.isConnected(NetworkType.WIFI) || NetworkManager.networkManager.isConnected(NetworkType.CELLULAR) ) { //we have connection!! doSomething(); } else { //no connection =( showError(); }

However, this always returns false. It seems that the simulator uses another kind of network not identified by NetworkType constants. I think this happens because VMWare makes connection possible through black magic.

So i am not sure if I should stick to this code and hope it will work in a real device using WiFi or Cellular network, or should find another approach for what I need.

I've also tried doing this (passing no parameters)

NetworkManager.networkManager.isConnected()

but it will always return true despite if I have internet connection or not in my PC. I think VMWare is trolling me again.

So, any advice on how should I do this for better results in a real device?

Answer1:

Well, just to update. I finally got a BBZ10, and had a chance to try this code. It seems that NetworkManager.networkManager.isConnected(NetworkType.WIFI) and NetworkManager.networkManager.isConnected(NetworkType.CELLULAR) will work the way they are expected, even if the emulator can't really emulate their funcionality.

So, if you really need this functionality, go ahead and try this, it WILL really work once deployed.

Recommend

  • Does C allow parameter by address?
  • git: 'http-push' is not a git command. fatal: git-http-push failed
  • Can't eliminate Access corruption
  • How to use USB over Remote Connection to a Virtual Machine
  • Trigger once after event created using fullcalendar.io
  • Android studio 3.1 rebuild project each time to see the changes
  • How can I migrate my WP8 application to universal when it uses a local linq to sql db?
  • Drupal: Hierarchical taxonomical breadcrumb trail
  • Maintaining XML comments during XSL Transformations
  • Socket.io on socket disconnect
  • How do CL commands build their exact parameter lists?
  • Controlling Prolog variable value selection
  • Hakyll says “Dependency cycle detected: …”
  • How to load Q library with Require.js?
  • Android mkdirs() sdcard do not work
  • in batch how do i use taskkill properly
  • NHibernate manually control fetching
  • Private IP address in reserved subnet range
  • Clear activity stack before launching another activity
  • Javascript, Regex - I need to grab each section of a string contained in brackets
  • Saving image to sd with current date and time in name doesn't work
  • Refering to the class itself from within a class mehod in Objective C
  • Yii2: Config params vs. const/define
  • Ajax Loaded meta Tags
  • formatting the colorbar ticklabels with SymLogNorm normalization in matplotlib
  • script to move all files from one location to another location
  • Fill an image in a square container while keeping aspect ratio
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • KeystoneJS: Relationships in Admin UI not updating
  • Error creating VM instance in Google Compute Engine
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How can I remove ASP.NET Designer.cs files?
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • costura.fody for a dll that references another dll
  • Reading document lines to the user (python)
  • Binding checkboxes to object values in AngularJs
  • java string with new operator and a literal