Wifi configuration and util library built for Android.
Developed by Patches 04/24/2016 - present
Supports Android SDK levels 16-25
Make sure you have one of the following repositories accessible:
repositories {
jcenter()
}
repositories {
mavenCentral()
}
repositories {
maven {
url "http://dl.bintray.com/isupatches/Maven"
}
}
Then add it as a dependency:
Gradle:
compile 'com.isupatches:wisefy:1.0.7'
Maven:
<dependency>
<groupId>com.isupatches</groupId>
<artifactId>wisefy</artifactId>
<version>1.0.7</version>
<type>pom</type>
</dependency>
You may also download the @aar from the releases page and import it into your project manually.
WiseFy now supports the builder pattern so cool functionality can be added later!
To grab a default instance:
WiseFy mWiseFy = new WiseFy.withContext(getActivity()).getSmarts();
To grab an instance with logging enabled:
WiseFy mWiseFy = new WiseFy.withContext(getActivity()).logging(true).getSmarts();
To add an open network:
int addedSuccessfully = mWiseFy.addOpenNetwork("Open Network");
To add a WEP network:
int addedSuccessfully = mWiseFy.addWEPNetwork("WEP Network", "123456");
To add a WPA2 network:
int addedSuccessfully = mWiseFy.addWPA2Network("WPA2 Network", "12345678");
To calculate number of bars given a networks signal strength and total number of bars:
int bars = mWiseFy.calculateBars(-35, -5);
To compare the signal strength of two networks:
int result = mWiseFy.compareSignalLevel(-35, -70);
To connect to a network given an SSID:
boolean connectedSuccessfully = mWiseFy.connectToNetwork("SSID To Reconnect To", 30000);
To disable wifi:
boolean disabledWifiSuccessfully = mWiseFy.disableWifi();
To disconnect from current network:
boolean disconnectedSuccessfully = mWiseFy.disconnectFromCurrentNetwork();
To enable wifi:
boolean wifiEnabled = mWiseFy.enableWiFi();
To get current network:
WifiInfo currentNetwork = mWiseFy.getCurrentNetwork();
To get the frequency of the devices current network:
* NOTE * Only supported on API >= 21
int frequency = mWiseFy.getFrequency();
To get the frequency of a network:
* NOTE * Only supported on API >= 21
int frequency = mWiseFy.getFrequency(wifiInfo);
To get nearby access points:
Setting filterDuplicates to true will not return SSIDs with a weaker signal strength (will always take the highest)
List<ScanResult> nearbyAccessPoints = mWiseFy.getNearbyAccessPoints(true);
To get the networks whose configuration is already stored:
List<WifiConfiguration> savedNetworks = mWiseFy.getSavedNetworks();
To check and see if the device is connected to a mobile network:
boolean isConnected = mWiseFy.isDeviceConnectedToMobileNetwork();
To check and see if the device is connected to a mobile or wifi network:
boolean isConnected = mWiseFy.isDeviceConnectedToMobileOrWifiNetwork();
To check and see if the device is connected to a given SSID:
boolean isConnected = mWiseFy.isDeviceConnectedToSSID("SSID");
To check and see if the device is connected to a wifi network:
boolean isConnected = mWiseFy.isDeviceConnectedToWifiNetwork();
To check if the device's current network is 5gHz:
* NOTE * Only supported on API >= 21
boolean is5gHz = mWiseFy.isNetwork5gHz();
To check if a network is 5gHz:
* NOTE * Only supported on API >= 21
boolean is5gHz = mWiseFy.isNetwork5gHz(wifiInfo);
To check and see if a given SSID is in the devices set of configured networks:
boolean isConfigured = mWiseFy.isNetworkInConfigurationList("SSID");
To check and see if a network is secure (WEP/PSK/EAP capabilities):
boolean isSecure = mWiseFy.isNetworkSecure(scanResult);
To check and see if Wifi is enabled on a device:
boolean wifiEnabled = mWiseFy.isWifiEnabled();
To remove a configured network:
boolean removedSuccessfully = mWiseFy.removeNetwork("SSID To Remove");
To search for an SSID given a search string:
String ssid = mWiseFy.searchForSSID("SSID To Search For", 30000);
Copyright 2017 Patches Klinefelter
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.