The below code does not seem to be working. This depends on the Cordova Network plug in right? The only value I get back is false.
Am I using this correctly?
The below code does not seem to be working. This depends on the Cordova Network plug in right? The only value I get back is false.
Am I using this correctly?
Hello Ryan,
You are right, that action relies in the Cordova Network plugin. And yes... in principle, must work. Are you executing that code after the app "Ready" event? I asume that yes (that is mandatory, since Cordova stuff is available in that or after that event). Can you please try with an "Alert" that just show the value of the variable that you pass to the action? So we can discard some possible mistake in the condition.
I have tried to test the GetNetworkType function using the Android Studio Emulator but it always returns false no mater what I set the network parameters to.
I am going to order a tablet today to test on a real device
Hello Ryan,
Humm... probably the plugin can't work in the emulator. I just test the action and the plugin here in an Android device and works as expected, so, probably you can see it also working in a real device.
It will be a more complete testing environment anyway. I will post back on this thread after I run it on the Android tablet.
Hello Ryan,
Yes; a real device is probably the best way to debug things that cannot be debugged in the browser(s). Not only more faster, but also better, because, as we can see here, the emulator don't support certain kind of stuff, that the device support.
Remember to install the Google USB drivers (if needed) and just connect the device to the computer. Then use the "Run" BAT file and the app must be automatically launched in the device after has been successfully compiled.
I got my test Android tablet today, and I ran the below code with both the wifi on and off. Running this test is always returning "false".
I built the apk and copied it over to the tablet and installed it on the tablet. FYI
Hello Ryan,
I think the problem is in the condition. You must use "&&" (AND) instead "||" (OR), because, in other case, we probably always fall in that condition and then the "hasNetwork" variable become false. So the condition must look something like:
About to copy the APK file and then install the app in the device... you can avoid that if properly connect the device via USB, and then use the "Run" BAT file.
Thanks David. I will give the && a try.
I connected the device via usb and I can browse the device using windows explorer, but when I use the Run BAT file, I get a message in the command window that it cannot find a device and so it tries to launch emulator. I will try installing the Google USB drivers .
Hello Ryan,
Yes; the USB drivers can do the trick. Anyway, try it, that is, look for it, because the debug process is faster in this way.
Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.
This website uses some useful cookies to store your preferences.