Skip to content

Wrapper around WifiManager and ConnectivityManager for Android

License

Notifications You must be signed in to change notification settings

mansya/WiseFy

 
 

Repository files navigation

WiseFy

Wifi configuration and util library built for Android.


Developed by Patches 04/24/2016 - present


Supports Android SDK levels 16-27

Build Status Download codecov

Android Arsenal Android Weekly

What's New in 3.x

  • Rewritten in Kotlin
    • Static analysis tools added
  • Ability to get the IP of a device
  • Additional details in callbacks for adding a network:
    • The new id of the network
    • The WifiConfiguration of the network that was added
  • isNetworkInConfigurationList renamed isNetworkSaved
  • brains renamed Brains
  • Nullability issues will be more visible
  • Definitions for NetworkTypes and WiseFyCodes
  • Immutability throughout the library
  • Improved architecture
  • Updated dependencies
  • Updated to Gradle 4.x and AGP 3.x
  • Target now is set to API 27
  • Less duplicate code
  • Improved testing
  • Updated documentation with new Kotlin examples
  • Other improvements and adjustments!

What's New in 2.0.x

  • Asynchronous API
    • Certain methods have callbacks and are run on a WiseFy specific background thread
  • Ability to search by regex for:
    • Nearby access points
    • Saved Configurations
    • SSIDs
  • Ability to query for RSSI
  • Ability to query for if the device is roaming
  • Additional methods to query for network security
  • Full fledged documentation directory
  • Tested against Android O

Adding to your project

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 (please see https://github.com/isuPatches/WiseFy/releases for the latest version):

For Gradle:

    compile 'com.isupatches:wisefy:<LATEST_VERSION>'

For Maven:

    <dependency>
      <groupId>com.isupatches</groupId>
      <artifactId>wisefy</artifactId>
      <version>LATEST_VERSION</version>
      <type>pom</type>
    </dependency>

You may also download the @aar from the releases page and import it into your project manually.

Getting An Instance

WiseFy is constructed with the builder pattern that allows you access to the synchronous and asynchronous APIs.

NOTE The context passed in must be non-null.

To grab a default instance:

With Kotlin

val wisefy = WiseFy.Brains(activity!!).getSmarts()

With Java

WiseFy wisefy = new WiseFy.Brains(getActivity()).getSmarts();

To grab an instance with logging enabled:

With Kotlin

val wisefy = WiseFy.Brains(activity!!).logging(true).getSmarts()

With Java

WiseFy wisefy = new WiseFy.Brains(getActivity()).logging(true).getSmarts();

Cleanup

Since the Async API of WiseFy is run on a background thread, it is necessary to make sure it is exited and cleanup up properly.

To stop the WiseFy thread and nullify it along with it's handler please call:

With Kotlin

wisefy.dump();

With Java

wisefy.dump();

Permissions

For the sake of transparency and because you're probably curious as to what permissions this library adds to your app, here are the additional expected permissions:

 <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

* NOTE *

If access points or SSIDs are not being returned on >= 6.x devices but there are visible networks, it's most likely because you haven't asked in your application for the Manifest.permission.ACCESS_COARSE_LOCATION permission which is what allows us to see the access points nearby. This permission request will not be added to the WiseFy library to reduce package bloat and so users can determine their own UI/UX.

Please check the permssions example for a sample of how to request permissions for WiseFy.

Usage

Please check the documentation markdown directory for usage examples and details about both the synchronous and asynchronous API.

License

Copyright 2018 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.

About

Wrapper around WifiManager and ConnectivityManager for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%