I needed a way to toggle WIFI-data programatically in a small app of mine but I couldn't find a way to do it in Basic4Android so I wrote this small library to toggle WIFI (disabled/enabled).
The java-code was easily found using Google. It was also a good exercise to get familiar with wrapping java-code and writing libraries for use with Basic4Android. I am sure the library can be written in a much better way but it does work (tested on Froyo and Gingerbread) and therefore I decided to share it with you.
Please note that the library does not check for connectivity-status. It only verifies if WIFI is enabled or disabled and gives you the possibility to turn it on or off.
I am also trying to extend this little library with the possibility to toggle 3G (mobile-data) and Bluetooth but so far I haven't been able to get the wrapper-code running. Maybe in the future if I am able to come to grip with java.
Library is attached and so is a small example-project.
Edit: 01/11/2011 - Updated library and got rid of ActivityObject annotation so it may be used within service-modules. I haven't tested it within a service-module so if it doesn't work, then let me know.
Edit2: 01/11/2011 - Forgot to change version-number. Now library shows correct version i.e. version 2.0
The java-code was easily found using Google. It was also a good exercise to get familiar with wrapping java-code and writing libraries for use with Basic4Android. I am sure the library can be written in a much better way but it does work (tested on Froyo and Gingerbread) and therefore I decided to share it with you.
Please note that the library does not check for connectivity-status. It only verifies if WIFI is enabled or disabled and gives you the possibility to turn it on or off.
I am also trying to extend this little library with the possibility to toggle 3G (mobile-data) and Bluetooth but so far I haven't been able to get the wrapper-code running. Maybe in the future if I am able to come to grip with java.
Library is attached and so is a small example-project.
Edit: 01/11/2011 - Updated library and got rid of ActivityObject annotation so it may be used within service-modules. I haven't tested it within a service-module so if it doesn't work, then let me know.
Edit2: 01/11/2011 - Forgot to change version-number. Now library shows correct version i.e. version 2.0
Attachments
Last edited: